Mercurial > hg > monetdb-java
comparison src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in @ 224:ea729e0cf24d
Improve and extend MonetDriver.getPropertyInfo() with choice values
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Thu, 03 May 2018 16:22:37 +0200 (2018-05-03) |
parents | e8139dbe3883 |
children | 51e886d7f3b4 27b7166860c8 |
comparison
equal
deleted
inserted
replaced
223:e8139dbe3883 | 224:ea729e0cf24d |
---|---|
210 @Override | 210 @Override |
211 public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) { | 211 public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) { |
212 if (!acceptsURL(url)) | 212 if (!acceptsURL(url)) |
213 return null; | 213 return null; |
214 | 214 |
215 List<DriverPropertyInfo> props = new ArrayList<DriverPropertyInfo>(); | 215 String[] boolean_choices = new String[] { "true", "false" }; |
216 | 216 String[] language_choices = new String[] { "sql", "mal" }; |
217 DriverPropertyInfo prop = new DriverPropertyInfo("user", info.getProperty("user")); | 217 String[] hash_choices = new String[] { "SHA512", "SHA384", "SHA256", "SHA1", "MD5" }; |
218 DriverPropertyInfo[] dpi = new DriverPropertyInfo[9]; // we currently support 9 connection properties | |
219 | |
220 DriverPropertyInfo prop = new DriverPropertyInfo("user", info != null ? info.getProperty("user") : null); | |
218 prop.required = true; | 221 prop.required = true; |
219 prop.description = "The user loginname to use when authenticating on the database server"; | 222 prop.description = "The user loginname to use when authenticating on the database server"; |
220 props.add(prop); | 223 dpi[0] = prop; |
221 | 224 |
222 prop = new DriverPropertyInfo("password", info.getProperty("password")); | 225 prop = new DriverPropertyInfo("password", info != null ? info.getProperty("password") : null); |
223 prop.required = true; | 226 prop.required = true; |
224 prop.description = "The password to use when authenticating on the database server"; | 227 prop.description = "The password to use when authenticating on the database server"; |
225 props.add(prop); | 228 dpi[1] = prop; |
226 | 229 |
227 prop = new DriverPropertyInfo("debug", "false"); | 230 prop = new DriverPropertyInfo("debug", "false"); |
228 prop.required = false; | 231 prop.required = false; |
229 prop.description = "Whether or not to create a log file for debugging purposes"; | 232 prop.description = "Whether or not to create a log file for debugging purposes"; |
230 props.add(prop); | 233 prop.choices = boolean_choices; |
231 | 234 dpi[2] = prop; |
232 prop = new DriverPropertyInfo("logfile", ""); | 235 |
236 prop = new DriverPropertyInfo("logfile", null); | |
233 prop.required = false; | 237 prop.required = false; |
234 prop.description = "The filename to write the debug log to. Only takes effect if debug is set to true. If the file exists, an incrementing number is added, till the filename is unique."; | 238 prop.description = "The filename to write the debug log to. Only takes effect if debug is set to true. If the file exists, an incrementing number is added, till the filename is unique."; |
235 props.add(prop); | 239 dpi[3] = prop; |
236 | 240 |
237 prop = new DriverPropertyInfo("language", "sql"); | 241 prop = new DriverPropertyInfo("language", "sql"); |
238 prop.required = false; | 242 prop.required = false; |
239 prop.description = "What language to use for MonetDB conversations (experts only)"; | 243 prop.description = "What language to use for MonetDB conversations (experts only)"; |
240 props.add(prop); | 244 prop.choices = language_choices; |
241 | 245 dpi[4] = prop; |
242 prop = new DriverPropertyInfo("hash", ""); | 246 |
247 prop = new DriverPropertyInfo("hash", null); | |
243 prop.required = false; | 248 prop.required = false; |
244 prop.description = "Force the use of the given hash algorithm during challenge response (one of SHA1, MD5, plain)"; | 249 prop.description = "Force the use of the given hash algorithm during challenge response (one of SHA1, MD5, plain)"; |
245 props.add(prop); | 250 prop.choices = hash_choices; |
246 | 251 dpi[5] = prop; |
252 | |
253 prop = new DriverPropertyInfo("treat_blob_as_binary", "false"); | |
254 prop.required = false; | |
255 prop.description = "Should blob columns be mapped to Types.VARBINARY instead of default Types.BLOB in ResultSets and PreparedStatements"; | |
256 prop.choices = boolean_choices; | |
257 dpi[6] = prop; | |
258 | |
259 prop = new DriverPropertyInfo("treat_clob_as_varchar", "false"); | |
260 prop.required = false; | |
261 prop.description = "Should clob columns be mapped to Types.VARCHAR instead of default Types.CLOB in ResultSets and PreparedStatements"; // recommend for increased performance due to less overhead | |
262 prop.choices = boolean_choices; | |
263 dpi[7] = prop; | |
264 | |
265 prop = new DriverPropertyInfo("so_timeout", "0"); | |
266 prop.required = false; | |
267 prop.description = "Defines the maximum time to wait in milliseconds on a blocking read socket call"; // this corresponds to the Connection.setNetworkTimeout() method introduced in JDBC 4.1 | |
268 dpi[8] = prop; | |
269 | |
270 /* next property is no longer supported in: new MonetConnection(props) | |
247 prop = new DriverPropertyInfo("follow_redirects", "true"); | 271 prop = new DriverPropertyInfo("follow_redirects", "true"); |
248 prop.required = false; | 272 prop.required = false; |
249 prop.description = "Whether redirects issued by the server should be followed"; | 273 prop.description = "Whether redirects issued by the server should be followed"; |
250 props.add(prop); | 274 prop.choices = boolean_choices; |
251 | 275 dpi[9] = prop; |
252 prop = new DriverPropertyInfo("treat_blob_as_binary", "false"); | 276 */ |
253 prop.required = false; | 277 |
254 prop.description = "Whether BLOBs on the server should be treated as BINARY types, thus mapped to byte[]"; | 278 return dpi; |
255 props.add(prop); | |
256 | |
257 prop = new DriverPropertyInfo("treat_clob_as_varchar", "false"); | |
258 prop.required = false; | |
259 prop.description = "Whether CLOBs on the server should be treated and handled as VARCHAR types in the JDBC driver"; // recommend for increased performance due to less overhead | |
260 props.add(prop); | |
261 | |
262 prop = new DriverPropertyInfo("so_timeout", "0"); | |
263 prop.required = false; | |
264 prop.description = "Defines the maximum time to wait in milliseconds on a blocking read socket call"; // this corresponds to the Connection.setNetworkTimeout() method introduced in JDBC 4.1 | |
265 props.add(prop); | |
266 | |
267 DriverPropertyInfo[] dpi = new DriverPropertyInfo[props.size()]; | |
268 return props.toArray(dpi); | |
269 } | 279 } |
270 | 280 |
271 /** | 281 /** |
272 * Reports whether this driver is a genuine JDBC Compliant™ driver. A | 282 * Reports whether this driver is a genuine JDBC Compliant™ driver. A |
273 * driver may only report true here if it passes the JDBC compliance tests; | 283 * driver may only report true here if it passes the JDBC compliance tests; |