Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
Long connectionPoolSize;
Long listenerPoolSize;
String partnerToken;
private static DatabaseMetaData databaseMetaData;
DatabaseMetaData databaseMetaData;

BigQueryConnection(String url) throws IOException {
this(url, DataSource.fromUrl(url));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class BigQueryDatabaseMetaData implements DatabaseMetaData {

String URL;
BigQueryConnection connection;
Statement statement = null;
private final BigQuery bigquery;
private final int metadataFetchThreadCount;
private static final AtomicReference<String> parsedDriverVersion = new AtomicReference<>(null);
Expand All @@ -147,7 +148,7 @@ class BigQueryDatabaseMetaData implements DatabaseMetaData {
private static final AtomicReference<Integer> parsedDriverMinorVersion =
new AtomicReference<>(null);

BigQueryDatabaseMetaData(BigQueryConnection connection) throws SQLException {
BigQueryDatabaseMetaData(BigQueryConnection connection) {
this.URL = connection.getConnectionUrl();
this.connection = connection;
this.bigquery = connection.getBigQuery();
Expand Down Expand Up @@ -2632,10 +2633,11 @@ Schema defineGetVersionColumnsSchema() {
public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
String sql = readSqlFromFile(GET_PRIMARY_KEYS_SQL);
try {
Statement stmt = this.connection.createStatement();
stmt.closeOnCompletion();
if (this.statement == null) {
this.statement = this.connection.createStatement();
}
String formattedSql = replaceSqlParameters(sql, catalog, schema, table);
return stmt.executeQuery(formattedSql);
return this.statement.executeQuery(formattedSql);
} catch (SQLException e) {
throw new BigQueryJdbcException(e);
}
Expand All @@ -2646,10 +2648,11 @@ public ResultSet getImportedKeys(String catalog, String schema, String table)
throws SQLException {
String sql = readSqlFromFile(GET_IMPORTED_KEYS_SQL);
try {
Statement stmt = this.connection.createStatement();
stmt.closeOnCompletion();
if (this.statement == null) {
this.statement = this.connection.createStatement();
}
String formattedSql = replaceSqlParameters(sql, catalog, schema, table);
return stmt.executeQuery(formattedSql);
return this.statement.executeQuery(formattedSql);
} catch (SQLException e) {
throw new BigQueryJdbcException(e);
}
Expand All @@ -2660,10 +2663,11 @@ public ResultSet getExportedKeys(String catalog, String schema, String table)
throws SQLException {
String sql = readSqlFromFile(GET_EXPORTED_KEYS_SQL);
try {
Statement stmt = this.connection.createStatement();
stmt.closeOnCompletion();
if (this.statement == null) {
this.statement = this.connection.createStatement();
}
String formattedSql = replaceSqlParameters(sql, catalog, schema, table);
return stmt.executeQuery(formattedSql);
return this.statement.executeQuery(formattedSql);
} catch (SQLException e) {
throw new BigQueryJdbcException(e);
}
Expand All @@ -2680,8 +2684,9 @@ public ResultSet getCrossReference(
throws SQLException {
String sql = readSqlFromFile(GET_CROSS_REFERENCE_SQL);
try {
Statement stmt = this.connection.createStatement();
stmt.closeOnCompletion();
if (this.statement == null) {
this.statement = this.connection.createStatement();
}
String formattedSql =
replaceSqlParameters(
sql,
Expand All @@ -2691,7 +2696,7 @@ public ResultSet getCrossReference(
foreignCatalog,
foreignSchema,
foreignTable);
return stmt.executeQuery(formattedSql);
return this.statement.executeQuery(formattedSql);
} catch (SQLException e) {
throw new BigQueryJdbcException(e);
}
Expand Down
Loading