Skip to content
Permalink
Browse files
DRILL-8227: JConnect and jTDS JDBC drivers do not implement Connectio…
…n::getSchema (#2551)
  • Loading branch information
jnturton committed May 19, 2022
1 parent aed78f3 commit 0213d8e77d6739fcd9072719743ba06a4a3744ba
Showing 4 changed files with 444 additions and 2 deletions.
@@ -35,6 +35,8 @@
<clickhouse.jdbc.version>0.3.1</clickhouse.jdbc.version>
<h2.version>2.1.210</h2.version>
<postgresql.version>42.3.3</postgresql.version>
<mssql-jdbc.version>9.2.0.jre8</mssql-jdbc.version>
<jtds.version>1.3.1</jtds.version>
</properties>

<dependencies>
@@ -85,6 +87,20 @@
<version>${postgresql.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- Even if our unit tests of MSSQL use the jtds driver, the mssql-jdbc
driver is still required by testcontainers. -->
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${mssql-jdbc.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>${jtds.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
@@ -115,6 +131,12 @@
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mssqlserver</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
@@ -52,11 +52,21 @@ class JdbcCatalogSchema extends AbstractSchema {
String connectionSchemaName = null;
try (Connection con = source.getConnection();
ResultSet set = con.getMetaData().getCatalogs()) {
connectionSchemaName = con.getSchema();

try {
connectionSchemaName = con.getSchema();
} catch (AbstractMethodError ex) {
// DRILL-8227. Some Sybase JDBC drivers still don't implement this method, e.g. JConnect, jTDS.
logger.warn(
"{} does not provide an implementation of getSchema(), default schema will be guessed",
con.getClass()
);
}

while (set.next()) {
final String catalogName = set.getString(1);
if (catalogName == null) {
// DB2 is an example of why of this escape is needed.
// DRILL-8219. DB2 is an example of why of this escape is needed.
continue;
}

0 comments on commit 0213d8e

Please sign in to comment.