提交 d6f8e0e6 authored 作者: Thomas Mueller's avatar Thomas Mueller

DatabaseMetaData.getJDBCMajorVersion now returns 4 (instead of 3) when the…

DatabaseMetaData.getJDBCMajorVersion now returns 4 (instead of 3) when the driver is compiled with Java 6 (the default).
上级 b7a0163d
...@@ -2639,12 +2639,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2639,12 +2639,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* CLOSE_CURSORS_AT_COMMIT * CLOSE_CURSORS_AT_COMMIT
* @return true if the holdability is ResultSet.CLOSE_CURSORS_AT_COMMIT * @return true if the holdability is ResultSet.CLOSE_CURSORS_AT_COMMIT
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public boolean supportsResultSetHoldability(int holdability) { public boolean supportsResultSetHoldability(int holdability) {
debugCodeCall("supportsResultSetHoldability", holdability); debugCodeCall("supportsResultSetHoldability", holdability);
return holdability == ResultSet.CLOSE_CURSORS_AT_COMMIT; return holdability == ResultSet.CLOSE_CURSORS_AT_COMMIT;
} }
//## Java 1.4 end ## //## Java 1.4 end ##
/** /**
* Gets the result set holdability. * Gets the result set holdability.
...@@ -2680,12 +2680,18 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2680,12 +2680,18 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
/** /**
* Gets the major version of the supported JDBC API. * Gets the major version of the supported JDBC API.
* This method returns 4 when the driver is compiled using Java 5 or 6.
* It returns 3 otherwise.
* *
* @return the major version (3) * @return the major version (4 or 3)
*/ */
public int getJDBCMajorVersion() { public int getJDBCMajorVersion() {
debugCodeCall("getJDBCMajorVersion"); debugCodeCall("getJDBCMajorVersion");
return 3; int majorVersion = 3;
//## Java 1.6 begin ##
majorVersion = 4;
//## Java 1.6 end ##
return majorVersion;
} }
/** /**
...@@ -2703,12 +2709,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2703,12 +2709,12 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* *
* @return DatabaseMetaData.sqlStateSQL99 * @return DatabaseMetaData.sqlStateSQL99
*/ */
//## Java 1.4 begin ## //## Java 1.4 begin ##
public int getSQLStateType() { public int getSQLStateType() {
debugCodeCall("getSQLStateType"); debugCodeCall("getSQLStateType");
return DatabaseMetaData.sqlStateSQL99; return DatabaseMetaData.sqlStateSQL99;
} }
//## Java 1.4 end ## //## Java 1.4 end ##
/** /**
* Does the database make a copy before updating. * Does the database make a copy before updating.
...@@ -2754,22 +2760,22 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2754,22 +2760,22 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
* *
* @return ROWID_UNSUPPORTED * @return ROWID_UNSUPPORTED
*/ */
//## Java 1.6 begin ## //## Java 1.6 begin ##
public RowIdLifetime getRowIdLifetime() { public RowIdLifetime getRowIdLifetime() {
debugCodeCall("getRowIdLifetime"); debugCodeCall("getRowIdLifetime");
return RowIdLifetime.ROWID_UNSUPPORTED; return RowIdLifetime.ROWID_UNSUPPORTED;
} }
//## Java 1.6 end ## //## Java 1.6 end ##
/** /**
* [Not supported] Gets the list of schemas. * [Not supported] Gets the list of schemas.
*/ */
//## Java 1.6 begin ## //## Java 1.6 begin ##
public ResultSet getSchemas(String catalog, String schemaPattern) public ResultSet getSchemas(String catalog, String schemaPattern)
throws SQLException { throws SQLException {
throw unsupported("getSchemas(., .)"); throw unsupported("getSchemas(., .)");
} }
//## Java 1.6 end ## //## Java 1.6 end ##
/** /**
* Returns whether the database supports calling functions using the call syntax. * Returns whether the database supports calling functions using the call syntax.
...@@ -2801,41 +2807,41 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat ...@@ -2801,41 +2807,41 @@ public class JdbcDatabaseMetaData extends TraceObject implements DatabaseMetaDat
/** /**
* [Not supported] Return an object of this class if possible. * [Not supported] Return an object of this class if possible.
*/ */
//## Java 1.6 begin ## //## Java 1.6 begin ##
public <T> T unwrap(Class<T> iface) throws SQLException { public <T> T unwrap(Class<T> iface) throws SQLException {
throw unsupported("unwrap"); throw unsupported("unwrap");
} }
//## Java 1.6 end ## //## Java 1.6 end ##
/** /**
* [Not supported] Checks if unwrap can return an object of this class. * [Not supported] Checks if unwrap can return an object of this class.
*/ */
//## Java 1.6 begin ## //## Java 1.6 begin ##
public boolean isWrapperFor(Class< ? > iface) throws SQLException { public boolean isWrapperFor(Class< ? > iface) throws SQLException {
throw unsupported("isWrapperFor"); throw unsupported("isWrapperFor");
} }
//## Java 1.6 end ## //## Java 1.6 end ##
/** /**
* [Not supported] Gets the list of function columns. * [Not supported] Gets the list of function columns.
*/ */
//## Java 1.6 begin ## //## Java 1.6 begin ##
public ResultSet getFunctionColumns(String catalog, String schemaPattern, public ResultSet getFunctionColumns(String catalog, String schemaPattern,
String functionNamePattern, String columnNamePattern) String functionNamePattern, String columnNamePattern)
throws SQLException { throws SQLException {
throw unsupported("getFunctionColumns"); throw unsupported("getFunctionColumns");
} }
//## Java 1.6 end ## //## Java 1.6 end ##
/** /**
* [Not supported] Gets the list of functions. * [Not supported] Gets the list of functions.
*/ */
//## Java 1.6 begin ## //## Java 1.6 begin ##
public ResultSet getFunctions(String catalog, String schemaPattern, public ResultSet getFunctions(String catalog, String schemaPattern,
String functionNamePattern) throws SQLException { String functionNamePattern) throws SQLException {
throw unsupported("getFunctions"); throw unsupported("getFunctions");
} }
//## Java 1.6 end ## //## Java 1.6 end ##
/** /**
* INTERNAL * INTERNAL
......
...@@ -423,7 +423,11 @@ public class TestMetaData extends TestBase { ...@@ -423,7 +423,11 @@ public class TestMetaData extends TestBase {
assertTrue(meta.getDatabaseProductVersion().startsWith(versionStart)); assertTrue(meta.getDatabaseProductVersion().startsWith(versionStart));
assertEquals(meta.getDatabaseMajorVersion(), meta.getDriverMajorVersion()); assertEquals(meta.getDatabaseMajorVersion(), meta.getDriverMajorVersion());
assertEquals(meta.getDatabaseMinorVersion(), meta.getDriverMinorVersion()); assertEquals(meta.getDatabaseMinorVersion(), meta.getDriverMinorVersion());
assertEquals(3, meta.getJDBCMajorVersion()); int majorVersion = 3;
//## Java 1.6 begin ##
majorVersion = 4;
//## Java 1.6 end ##
assertEquals(majorVersion, meta.getJDBCMajorVersion());
assertEquals(0, meta.getJDBCMinorVersion()); assertEquals(0, meta.getJDBCMinorVersion());
} }
assertEquals("H2", meta.getDatabaseProductName()); assertEquals("H2", meta.getDatabaseProductName());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论