Mercurial > hg > monetdb-java
diff src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in @ 333:55330e40cbf1
Eliminate the need for private static final variables which are filled by preproccesor.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Wed, 25 Sep 2019 14:26:34 +0200 (2019-09-25) |
parents | 003ae6d881db |
children | 11e1ccef1cf6 |
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in +++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetDriver.java.in @@ -20,7 +20,7 @@ import java.util.Map.Entry; import java.util.Properties; /** - * A Driver suitable for the MonetDB database. + * A JDBC Driver suitable for the MonetDB RDBMS. * * This driver will be used by the DriverManager to determine if an URL * is to be handled by this driver, and if it does, then this driver @@ -30,31 +30,19 @@ import java.util.Properties; * generated by the Java compiler will be sufficient since nothing has * to be set in order to use this driver. * - * This Driver supports MonetDB database URLs. MonetDB URLs are defined - * as: + * This Driver supports MonetDB database URLs. MonetDB URLs are defined as: * <tt>jdbc:monetdb://<host>[:<port>]/<database></tt> * where [:<port>] denotes that a port is optional. If not * given the default (@JDBC_DEF_PORT@) will be used. * * @author Fabian Groffen - * @version @JDBC_MAJOR@.@JDBC_MINOR@ (@JDBC_VER_SUFFIX@) + * @version @JDBC_MAJOR@.@JDBC_MINOR@ (@JDBC_VER_SUFFIX@) based on MCL v@MCL_MAJOR@.@MCL_MINOR@" */ final public class MonetDriver implements Driver { // the url kind will be jdbc:monetdb://<host>[:<port>]/<database> // Chapter 9.2.1 from Sun JDBC 3.0 specification /** The prefix of a MonetDB url */ static final String MONETURL = "jdbc:monetdb://"; - /** Major version of this driver */ - private static final int DRIVERMAJOR = @JDBC_MAJOR@; - /** Minor version of this driver */ - private static final int DRIVERMINOR = @JDBC_MINOR@; - /** Version suffix string */ - private static final String DRIVERVERSIONSUFFIX = - "@JDBC_VER_SUFFIX@ based on MCL v@MCL_MAJOR@.@MCL_MINOR@"; - - /** MonetDB default port to connect to */ - private static final String PORT = "@JDBC_DEF_PORT@"; - // initialize this class: register it at the DriverManager // Chapter 9.2 from Sun JDBC 3.0 specification @@ -112,7 +100,7 @@ final public class MonetDriver implement final Properties props = new Properties(); // set the optional properties and their defaults here - props.put("port", PORT); + props.put("port", "@JDBC_DEF_PORT@"); props.put("debug", "false"); props.put("language", "sql"); // mal, sql, <future> props.put("so_timeout", "0"); @@ -169,7 +157,7 @@ final public class MonetDriver implement */ @Override public int getMajorVersion() { - return DRIVERMAJOR; + return @JDBC_MAJOR@; } /** @@ -179,7 +167,7 @@ final public class MonetDriver implement */ @Override public int getMinorVersion() { - return DRIVERMINOR; + return @JDBC_MINOR@; } /** @@ -205,8 +193,6 @@ final public class MonetDriver implement return null; final String[] boolean_choices = new String[] { "true", "false" }; - final String[] language_choices = new String[] { "sql", "mal" }; - final String[] hash_choices = new String[] { "SHA512", "SHA384", "SHA256", "SHA1", "MD5" }; final DriverPropertyInfo[] dpi = new DriverPropertyInfo[9]; // we currently support 9 connection properties DriverPropertyInfo prop = new DriverPropertyInfo("user", info != null ? info.getProperty("user") : null); @@ -233,13 +219,13 @@ final public class MonetDriver implement prop = new DriverPropertyInfo("language", "sql"); prop.required = false; prop.description = "What language to use for MonetDB conversations (experts only)"; - prop.choices = language_choices; + prop.choices = new String[] { "sql", "mal" }; dpi[4] = prop; prop = new DriverPropertyInfo("hash", null); prop.required = false; prop.description = "Force the use of the given hash algorithm during challenge response (one of SHA1, MD5, plain)"; - prop.choices = hash_choices; + prop.choices = new String[] { "SHA512", "SHA384", "SHA256", "SHA1", "MD5" }; dpi[5] = prop; prop = new DriverPropertyInfo("treat_blob_as_binary", "false"); @@ -315,6 +301,26 @@ final public class MonetDriver implement //== end methods of interface driver + /** + * utility methods called by MonetDatabaseMetaData methods + */ + static final int getDriverMajorVersion() { + return @JDBC_MAJOR@; + } + + static final int getDriverMinorVersion() { + return @JDBC_MINOR@; + } + + /** + * Returns a touched up identifying version string of this driver. + * It is made public as it is called from nl/cwi/monetdb/client/JdbcClient.java + * @return the version string + */ + public static final String getDriverVersion() { + return "@JDBC_MAJOR@.@JDBC_MINOR@ (@JDBC_VER_SUFFIX@ based on MCL v@MCL_MAJOR@.@MCL_MINOR@)"; + } + /** A static Map containing the mapping between MonetDB types and Java SQL types */ /* use SELECT sqlname, * FROM sys.types order by 1, id; to view all MonetDB types */ /* see http://docs.oracle.com/javase/7/docs/api/java/sql/Types.html to view all supported java SQL types */ @@ -400,21 +406,4 @@ final public class MonetDriver implement } return "CASE " + column + TypeMapppingSQL; } - - /** - * Returns a touched up identifying version string of this driver. - * It is made public as it is called from nl/cwi/monetdb/client/JdbcClient.java - * @return the version string - */ - public static final String getDriverVersion() { - return DRIVERMAJOR + "." + DRIVERMINOR + " (" + DRIVERVERSIONSUFFIX + ")"; - } - - static final int getDriverMajorVersion() { - return DRIVERMAJOR; - } - - static final int getDriverMinorVersion() { - return DRIVERMINOR; - } }