Skip to content

Commit f0c43cc

Browse files
committed
complete the rest of the files
1 parent f3d7ba8 commit f0c43cc

3 files changed

Lines changed: 36 additions & 15 deletions

File tree

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ protected SQLException createCoercionException(
124124
type = arrayField.getType().getStandardType();
125125
typeName = type.name();
126126
} else {
127-
throw new SQLException(
128-
"For a nested ResultSet from an Array, columnIndex must be 1 or 2.", cause);
127+
SQLException ex =
128+
new SQLException(
129+
"For a nested ResultSet from an Array, columnIndex must be 1 or 2.", cause);
130+
LOG.severe(ex, "For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
131+
throw ex;
129132
}
130133
} else {
131134
Field field = this.schemaFieldList.get(columnIndex - 1);
@@ -145,18 +148,25 @@ private StandardSQLTypeName getStandardSQLTypeName(int columnIndex) throws SQLEx
145148
return StandardSQLTypeName.INT64;
146149
} else if (columnIndex == 2) {
147150
if (this.schema == null || this.schema.getFields().isEmpty()) {
148-
throw new SQLException("Schema not available for nested result set.");
151+
SQLException ex = new SQLException("Schema not available for nested result set.");
152+
LOG.severe(ex, "Schema not available for nested result set.");
153+
throw ex;
149154
}
150155
Field arrayField = this.schema.getFields().get(0);
151156
return arrayField.getType().getStandardType();
152157
} else {
153-
throw new SQLException("For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
158+
SQLException ex =
159+
new SQLException("For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
160+
LOG.severe(ex, "For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
161+
throw ex;
154162
}
155163
} else {
156164
if (this.schemaFieldList == null
157165
|| columnIndex > this.schemaFieldList.size()
158166
|| columnIndex < 1) {
159-
throw new SQLException("Invalid column index: " + columnIndex);
167+
SQLException ex = new SQLException("Invalid column index: " + columnIndex);
168+
LOG.severe(ex, "Invalid column index: " + columnIndex);
169+
throw ex;
160170
}
161171
Field field = this.schemaFieldList.get(columnIndex - 1);
162172
return field.getType().getStandardType();

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5264,16 +5264,18 @@ private void loadDriverVersionProperties() {
52645264
if (input == null) {
52655265
String errorMessage =
52665266
"Could not find dependencies.properties. Driver version information is unavailable.";
5267-
LOG.severe(errorMessage);
5268-
throw new IllegalStateException(errorMessage);
5267+
IllegalStateException ex = new IllegalStateException(errorMessage);
5268+
LOG.severe(ex, errorMessage);
5269+
throw ex;
52695270
}
52705271
props.load(input);
52715272
String versionString = props.getProperty("version.jdbc");
52725273
if (versionString == null || versionString.trim().isEmpty()) {
52735274
String errorMessage =
52745275
"The property version.jdbc not found or empty in dependencies.properties.";
5275-
LOG.severe(errorMessage);
5276-
throw new IllegalStateException(errorMessage);
5276+
IllegalStateException ex = new IllegalStateException(errorMessage);
5277+
LOG.severe(ex, errorMessage);
5278+
throw ex;
52775279
}
52785280
parsedDriverVersion.compareAndSet(null, versionString.trim());
52795281
String[] parts = versionString.split("\\.");
@@ -5291,8 +5293,9 @@ private void loadDriverVersionProperties() {
52915293
"Error reading dependencies.properties. Driver version information is"
52925294
+ " unavailable. Error: "
52935295
+ e.getMessage();
5294-
LOG.severe(errorMessage);
5295-
throw new IllegalStateException(errorMessage, e);
5296+
IllegalStateException ex = new IllegalStateException(errorMessage, e);
5297+
LOG.severe(ex, errorMessage);
5298+
throw ex;
52965299
}
52975300
}
52985301
}

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryPreparedStatement.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,10 @@ private long bulkInsertWithWriteAPI(BigQueryWriteClient bigQueryWriteClient)
370370
jsonArray = new JsonArray();
371371
}
372372
} else {
373-
throw new BigQueryJdbcException("Mismatch between field count and parameter count.");
373+
BigQueryJdbcException ex =
374+
new BigQueryJdbcException("Mismatch between field count and parameter count.");
375+
LOG.severe(ex, "Mismatch between field count and parameter count.");
376+
throw ex;
374377
}
375378
}
376379
} catch (BigQueryJdbcException e) {
@@ -387,7 +390,9 @@ private long bulkInsertWithWriteAPI(BigQueryWriteClient bigQueryWriteClient)
387390
BatchCommitWriteStreamsResponse commitResponse =
388391
bigQueryWriteClient.batchCommitWriteStreams(commitRequest);
389392
if (commitResponse.hasCommitTime() == false) {
390-
throw new BigQueryJdbcException("Error committing the streams");
393+
BigQueryJdbcException ex = new BigQueryJdbcException("Error committing the streams");
394+
LOG.severe(ex, "Error committing the streams");
395+
throw ex;
391396
}
392397
LOG.finest("Commit called.");
393398
return rowCount;
@@ -398,8 +403,11 @@ private void setInsertMetadata(QueryStatistics statistics) throws SQLException {
398403
if (!statistics.getStatementType().equals(StatementType.INSERT)
399404
|| statistics.getSchema() == null
400405
|| statistics.getReferencedTables().stream().distinct().count() > 1) {
401-
throw new BigQueryJdbcException(
402-
"Use java.sql.Statement.executeBatch() for heterogeneous DML batches");
406+
BigQueryJdbcException ex =
407+
new BigQueryJdbcException(
408+
"Use java.sql.Statement.executeBatch() for heterogeneous DML batches");
409+
LOG.severe(ex, "Use java.sql.Statement.executeBatch() for heterogeneous DML batches");
410+
throw ex;
403411
}
404412

405413
this.insertSchema = statistics.getSchema();

0 commit comments

Comments
 (0)