From bf024c0e0b95c0163a26b503ee876752f2fabdb6 Mon Sep 17 00:00:00 2001 From: yrizhkov Date: Tue, 19 Dec 2023 12:11:13 +0200 Subject: [PATCH] return proper driver versions --- .../aerospike/jdbc/AerospikeDatabaseMetadata.java | 9 ++++++--- .../java/com/aerospike/jdbc/AerospikeDriver.java | 6 ++++-- .../java/com/aerospike/jdbc/util/Constants.java | 5 +++++ .../com/aerospike/jdbc/DatabaseMetadataTest.java | 15 +++++++-------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/aerospike/jdbc/AerospikeDatabaseMetadata.java b/src/main/java/com/aerospike/jdbc/AerospikeDatabaseMetadata.java index 1b1ab0f..c509550 100644 --- a/src/main/java/com/aerospike/jdbc/AerospikeDatabaseMetadata.java +++ b/src/main/java/com/aerospike/jdbc/AerospikeDatabaseMetadata.java @@ -30,6 +30,9 @@ import static com.aerospike.jdbc.util.AerospikeUtils.getCatalogIndexes; import static com.aerospike.jdbc.util.AerospikeUtils.getClusterInfo; +import static com.aerospike.jdbc.util.Constants.DRIVER_MAJOR_VERSION; +import static com.aerospike.jdbc.util.Constants.DRIVER_MINOR_VERSION; +import static com.aerospike.jdbc.util.Constants.DRIVER_VERSION; import static com.aerospike.jdbc.util.Constants.JDBC_MAJOR_VERSION; import static com.aerospike.jdbc.util.Constants.JDBC_MINOR_VERSION; import static com.aerospike.jdbc.util.Constants.PRIMARY_KEY_COLUMN_NAME; @@ -157,17 +160,17 @@ public String getDriverName() { @Override public String getDriverVersion() { - return "NA"; + return DRIVER_VERSION; } @Override public int getDriverMajorVersion() { - return 1; + return DRIVER_MAJOR_VERSION; } @Override public int getDriverMinorVersion() { - return 0; + return DRIVER_MINOR_VERSION; } @Override diff --git a/src/main/java/com/aerospike/jdbc/AerospikeDriver.java b/src/main/java/com/aerospike/jdbc/AerospikeDriver.java index 6bb5849..ea3a252 100644 --- a/src/main/java/com/aerospike/jdbc/AerospikeDriver.java +++ b/src/main/java/com/aerospike/jdbc/AerospikeDriver.java @@ -14,6 +14,8 @@ import java.util.Properties; import java.util.logging.Logger; +import static com.aerospike.jdbc.util.Constants.DRIVER_MAJOR_VERSION; +import static com.aerospike.jdbc.util.Constants.DRIVER_MINOR_VERSION; import static java.util.stream.Collectors.toList; public class AerospikeDriver implements Driver { @@ -55,11 +57,11 @@ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) { } public int getMajorVersion() { - return 1; + return DRIVER_MAJOR_VERSION; } public int getMinorVersion() { - return 0; + return DRIVER_MINOR_VERSION; } public boolean jdbcCompliant() { diff --git a/src/main/java/com/aerospike/jdbc/util/Constants.java b/src/main/java/com/aerospike/jdbc/util/Constants.java index a72f679..1994a59 100644 --- a/src/main/java/com/aerospike/jdbc/util/Constants.java +++ b/src/main/java/com/aerospike/jdbc/util/Constants.java @@ -7,6 +7,11 @@ public final class Constants { public static final String UNSUPPORTED_QUERY_TYPE_MESSAGE = "Unsupported query type"; + // Driver version + public static final String DRIVER_VERSION = "1.7.5"; + public static final int DRIVER_MAJOR_VERSION = 1; + public static final int DRIVER_MINOR_VERSION = 7; + // JDBC specification public static final String JDBC_VERSION = "4.2"; public static final int JDBC_MAJOR_VERSION = JDBC_VERSION.charAt(0) - '0'; diff --git a/src/test/java/com/aerospike/jdbc/DatabaseMetadataTest.java b/src/test/java/com/aerospike/jdbc/DatabaseMetadataTest.java index d5b9277..1e53edb 100644 --- a/src/test/java/com/aerospike/jdbc/DatabaseMetadataTest.java +++ b/src/test/java/com/aerospike/jdbc/DatabaseMetadataTest.java @@ -53,7 +53,7 @@ public void tearDown() throws SQLException { @Test public void testGetTables() throws SQLException { DatabaseMetaData databaseMetaData = connection.getMetaData(); - ResultSet tables = databaseMetaData.getTables(namespace, namespace, tableName, null); + ResultSet tables = databaseMetaData.getTables(namespace, "", tableName, null); if (tables.next()) { assertEquals(tables.getString("TABLE_NAME"), tableName); @@ -66,13 +66,12 @@ public void testGetTables() throws SQLException { public void testGetSchemas() throws SQLException { ResultSet schemas = connection.getMetaData().getSchemas(); - if (schemas.next()) { - String schemaName = schemas.getString(1); - String catalogName = schemas.getString(2); - assertEquals(schemas.getString("TABLE_SCHEM"), schemaName); - assertEquals(schemas.getString("TABLE_CATALOG"), catalogName); - assertFalse(schemas.next()); - } + assertTrue(schemas.next()); + String schemaName = schemas.getString(1); + String catalogName = schemas.getString(2); + assertEquals(schemas.getString("TABLE_SCHEM"), schemaName); + assertEquals(schemas.getString("TABLE_CATALOG"), catalogName); + assertFalse(schemas.next()); TestUtil.closeQuietly(schemas); }