Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/jdbc/MonetConnection.java @ 697:68422d7f3961
Inline isValidProperty() in checkValidProperty() as it is the only place the method is called. Also add javadoc comments.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Wed, 23 Nov 2022 21:09:06 +0100 (2022-11-23) |
parents | 07d60185eeb9 |
children | 940e266eeccd |
comparison
equal
deleted
inserted
replaced
696:07d60185eeb9 | 697:68422d7f3961 |
---|---|
295 server.setDatabase(database); | 295 server.setDatabase(database); |
296 server.setLanguage(language); | 296 server.setLanguage(language); |
297 | 297 |
298 // calculate our time zone offset | 298 // calculate our time zone offset |
299 final Calendar cal = Calendar.getInstance(); | 299 final Calendar cal = Calendar.getInstance(); |
300 int offsetMillis = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); | 300 final int offsetMillis = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET); |
301 int offsetSeconds = offsetMillis / 1000; | 301 final int offsetSeconds = offsetMillis / 1000; |
302 timeZoneSetting.set(offsetSeconds); | 302 timeZoneSetting.set(offsetSeconds); |
303 | 303 |
304 server.setHandshakeOptions(new HandshakeOption<?>[] { | 304 server.setHandshakeOptions(new HandshakeOption<?>[] { |
305 autoCommitSetting, | 305 autoCommitSetting, |
306 replySizeSetting, | 306 replySizeSetting, |
531 * ResultSet.CONCUR_UPDATABLE | 531 * ResultSet.CONCUR_UPDATABLE |
532 * @param resultSetHoldability one of the following ResultSet | 532 * @param resultSetHoldability one of the following ResultSet |
533 * constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or | 533 * constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or |
534 * ResultSet.CLOSE_CURSORS_AT_COMMIT | 534 * ResultSet.CLOSE_CURSORS_AT_COMMIT |
535 * | 535 * |
536 * @return a new Statement object that will generate ResultSet | 536 * @return a new Statement object that will generate ResultSet |
537 * objects with the given type, concurrency, and holdability | 537 * objects with the given type, concurrency, and holdability |
538 * @throws SQLException if a database access error occurs or the | 538 * @throws SQLException if a database access error occurs or the |
539 * given parameters are not ResultSet constants indicating type, | 539 * given parameters are not ResultSet constants indicating type, |
540 * concurrency, and holdability | 540 * concurrency, and holdability |
541 */ | 541 */ |
568 * | 568 * |
569 * @return the current catalog name or null if there is none | 569 * @return the current catalog name or null if there is none |
570 */ | 570 */ |
571 @Override | 571 @Override |
572 public String getCatalog() { | 572 public String getCatalog() { |
573 // MonetDB does NOT support catalogs | 573 // MonetDB does NOT support catalog names or qualifiers |
574 return null; | 574 return null; |
575 } | 575 } |
576 | 576 |
577 /** | 577 /** |
578 * Retrieves the current holdability of ResultSet objects created | 578 * Retrieves the current holdability of ResultSet objects created |
1102 * Connection object's database in which to work. If the driver | 1102 * Connection object's database in which to work. If the driver |
1103 * does not support catalogs, it will silently ignore this request. | 1103 * does not support catalogs, it will silently ignore this request. |
1104 */ | 1104 */ |
1105 @Override | 1105 @Override |
1106 public void setCatalog(final String catalog) { | 1106 public void setCatalog(final String catalog) { |
1107 // silently ignore this request as MonetDB does not support catalogs | 1107 // silently ignore this request as MonetDB does not support catalog names |
1108 } | 1108 } |
1109 | 1109 |
1110 /** | 1110 /** |
1111 * Changes the default holdability of ResultSet objects created using this | 1111 * Changes the default holdability of ResultSet objects created using this |
1112 * Connection object to the given holdability. The default holdability of | 1112 * Connection object to the given holdability. The default holdability of |
1205 * Installs the given TypeMap object as the type map for this | 1205 * Installs the given TypeMap object as the type map for this |
1206 * Connection object. The type map will be used for the custom | 1206 * Connection object. The type map will be used for the custom |
1207 * mapping of SQL structured types and distinct types. | 1207 * mapping of SQL structured types and distinct types. |
1208 * | 1208 * |
1209 * @param map the java.util.Map object to install as the replacement for | 1209 * @param map the java.util.Map object to install as the replacement for |
1210 * this Connection object's default type map | 1210 * this Connection object's default type map |
1211 */ | 1211 */ |
1212 @Override | 1212 @Override |
1213 public void setTypeMap(final Map<String, Class<?>> map) { | 1213 public void setTypeMap(final Map<String, Class<?>> map) { |
1214 typeMap = map; | 1214 typeMap = map; |
1215 } | 1215 } |
1825 if (lang == LANG_MAL) | 1825 if (lang == LANG_MAL) |
1826 sb.append("?language=mal"); | 1826 sb.append("?language=mal"); |
1827 return sb.toString(); | 1827 return sb.toString(); |
1828 } | 1828 } |
1829 | 1829 |
1830 /** | |
1831 * Utility method to validate if property name is supported. | |
1832 * If not supported a warning is added to this Connection. | |
1833 * @return valid true or false | |
1834 */ | |
1830 private boolean checkValidProperty(String name, String context) { | 1835 private boolean checkValidProperty(String name, String context) { |
1831 if (isValidProperty(name)) | 1836 // supported MonetDB connection properties. |
1837 // See also MonetDatabaseMetaData.getClientInfoProperties() | |
1838 if (name.equals("host") | |
1839 || name.equals("port") | |
1840 || name.equals("user") | |
1841 || name.equals("password") | |
1842 || name.equals("language") | |
1843 || name.equals("database") | |
1844 || name.equals("debug") | |
1845 || name.equals("logfile") | |
1846 || name.equals("hash") | |
1847 || name.equals("treat_blob_as_binary") | |
1848 || name.equals("treat_clob_as_varchar") | |
1849 || name.equals("autocommit") | |
1850 || name.equals("so_timeout") | |
1851 || name.equals("fetchsize")) // only supported by servers from version 11.41.1 onwards | |
1832 return true; | 1852 return true; |
1853 | |
1833 addWarning(context + ": '" + name + "' is not a recognised property", "01M07"); | 1854 addWarning(context + ": '" + name + "' is not a recognised property", "01M07"); |
1834 return false; | 1855 return false; |
1835 } | 1856 } |
1836 | |
1837 // supported MonetDB connection properties. | |
1838 // See also MonetDatabaseMetaData.getClientInfoProperties() | |
1839 private boolean isValidProperty(String name) { | |
1840 return name.equals("host") || | |
1841 name.equals("port") || | |
1842 name.equals("user") || | |
1843 name.equals("password") || | |
1844 name.equals("language") || | |
1845 name.equals("database") || | |
1846 name.equals("debug") || | |
1847 name.equals("logfile") || | |
1848 name.equals("hash") || | |
1849 name.equals("treat_blob_as_binary") || | |
1850 name.equals("treat_clob_as_varchar") || | |
1851 name.equals("autocommit") || | |
1852 name.equals("so_timeout") || | |
1853 name.equals("fetchsize"); // only supported by servers from version 11.41.1 onwards | |
1854 } | |
1855 | |
1856 | 1857 |
1857 // Internal caches for 3 static mserver environment values, so they aren't queried from mserver again and again | 1858 // Internal caches for 3 static mserver environment values, so they aren't queried from mserver again and again |
1858 private String env_current_user; | 1859 private String env_current_user; |
1859 private String env_monet_version; | 1860 private String env_monet_version; |
1860 private int maxConnections; | 1861 private int maxConnections; |