Skip to content

Commit db3d883

Browse files
committed
throw BigQueryJdbcException
1 parent de478c4 commit db3d883

12 files changed

Lines changed: 28 additions & 18 deletions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.google.cloud.bigquery.exception.BigQueryConversionException;
2828
import com.google.cloud.bigquery.exception.BigQueryJdbcCoercionException;
2929
import com.google.cloud.bigquery.exception.BigQueryJdbcCoercionNotFoundException;
30+
import com.google.cloud.bigquery.exception.BigQueryJdbcException;
3031
import java.io.InputStream;
3132
import java.io.Reader;
3233
import java.io.StringReader;
@@ -680,7 +681,7 @@ public <T> T unwrap(Class<T> iface) throws SQLException {
680681
if (iface.isInstance(this)) {
681682
return iface.cast(this);
682683
}
683-
throw new SQLException("Cannot unwrap to " + iface.getName());
684+
throw new BigQueryJdbcException("Cannot unwrap to " + iface.getName());
684685
}
685686

686687
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ public <T> T unwrap(Class<T> iface) throws SQLException {
12261226
if (iface.isInstance(this)) {
12271227
return iface.cast(this);
12281228
}
1229-
throw new SQLException("Cannot unwrap to " + iface.getName());
1229+
throw new BigQueryJdbcException("Cannot unwrap to " + iface.getName());
12301230
}
12311231

12321232
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4756,7 +4756,7 @@ public <T> T unwrap(Class<T> iface) throws SQLException {
47564756
if (iface.isInstance(this)) {
47574757
return iface.cast(this);
47584758
}
4759-
throw new SQLException("Cannot unwrap to " + iface.getName());
4759+
throw new BigQueryJdbcException("Cannot unwrap to " + iface.getName());
47604760
}
47614761

47624762
@Override

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.cloud.bigquery.Field.Mode;
2121
import com.google.cloud.bigquery.FieldList;
2222
import com.google.cloud.bigquery.StandardSQLTypeName;
23+
import com.google.cloud.bigquery.exception.BigQueryJdbcException;
2324
import java.sql.ResultSetMetaData;
2425
import java.sql.SQLException;
2526
import java.sql.Statement;
@@ -209,7 +210,7 @@ public <T> T unwrap(Class<T> iface) throws SQLException {
209210
if (iface.isInstance(this)) {
210211
return iface.cast(this);
211212
}
212-
throw new SQLException("Cannot unwrap to " + iface.getName());
213+
throw new BigQueryJdbcException("Cannot unwrap to " + iface.getName());
213214
}
214215

215216
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ public <T> T unwrap(Class<T> iface) throws SQLException {
16081608
if (iface.isInstance(this)) {
16091609
return iface.cast(this);
16101610
}
1611-
throw new SQLException("Cannot unwrap to " + iface.getName());
1611+
throw new BigQueryJdbcException("Cannot unwrap to " + iface.getName());
16121612
}
16131613

16141614
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ public <T> T unwrap(Class<T> iface) throws SQLException {
13721372
if (iface.isInstance(this)) {
13731373
return iface.cast(this);
13741374
}
1375-
throw new SQLException("Cannot unwrap to " + iface.getName());
1375+
throw new BigQueryJdbcException("Cannot unwrap to " + iface.getName());
13761376
}
13771377

13781378
@Override

java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSetTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.google.cloud.bigquery.Job;
3131
import com.google.cloud.bigquery.JobId;
3232
import com.google.cloud.bigquery.JobStatistics.QueryStatistics;
33+
import com.google.cloud.bigquery.exception.BigQueryJdbcException;
3334
import java.lang.reflect.Field;
3435
import java.sql.SQLException;
3536
import org.junit.jupiter.api.BeforeEach;
@@ -119,8 +120,8 @@ public void testWrapperMethods() throws SQLException {
119120
Object unwrappedImpl = resultSet.unwrap(BigQueryBaseResultSet.class);
120121
assertSame(unwrappedImpl, resultSet);
121122

122-
SQLException e =
123-
assertThrows(SQLException.class, () -> resultSet.unwrap(java.sql.Statement.class));
123+
BigQueryJdbcException e =
124+
assertThrows(BigQueryJdbcException.class, () -> resultSet.unwrap(java.sql.Statement.class));
124125
assertTrue(e.getMessage().contains("Cannot unwrap to java.sql.Statement"));
125126
}
126127
}

java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryConnectionTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,9 @@ public void testWrapperMethods() throws Exception {
513513
Object unwrappedImpl = connection.unwrap(BigQueryConnection.class);
514514
assertSame(unwrappedImpl, connection);
515515

516-
SQLException e =
517-
assertThrows(SQLException.class, () -> connection.unwrap(java.sql.Statement.class));
516+
BigQueryJdbcException e =
517+
assertThrows(
518+
BigQueryJdbcException.class, () -> connection.unwrap(java.sql.Statement.class));
518519
assertTrue(e.getMessage().contains("Cannot unwrap to java.sql.Statement"));
519520
}
520521
}

java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaDataTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.google.api.gax.paging.Page;
3333
import com.google.cloud.bigquery.*;
3434
import com.google.cloud.bigquery.BigQuery.RoutineListOption;
35+
import com.google.cloud.bigquery.exception.BigQueryJdbcException;
3536
import java.io.IOException;
3637
import java.io.InputStream;
3738
import java.sql.DatabaseMetaData;
@@ -3259,8 +3260,9 @@ public void testWrapperMethods() throws SQLException {
32593260
assertSame(dbMetadata, dbMetadata.unwrap(DatabaseMetaData.class));
32603261
assertSame(dbMetadata, dbMetadata.unwrap(BigQueryDatabaseMetaData.class));
32613262

3262-
SQLException e =
3263-
assertThrows(SQLException.class, () -> dbMetadata.unwrap(java.sql.Connection.class));
3263+
BigQueryJdbcException e =
3264+
assertThrows(
3265+
BigQueryJdbcException.class, () -> dbMetadata.unwrap(java.sql.Connection.class));
32643266
assertThat((Throwable) e).hasMessageThat().contains("Cannot unwrap to java.sql.Connection");
32653267
}
32663268

java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryResultSetMetadataTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.cloud.bigquery.LegacySQLTypeName;
2626
import com.google.cloud.bigquery.Schema;
2727
import com.google.cloud.bigquery.StandardSQLTypeName;
28+
import com.google.cloud.bigquery.exception.BigQueryJdbcException;
2829
import com.google.common.collect.ImmutableList;
2930
import java.sql.Array;
3031
import java.sql.ResultSetMetaData;
@@ -293,8 +294,9 @@ public void testWrapperMethods() throws SQLException {
293294
assertThat(unwrappedImpl).isNotSameInstanceAs(resultSetMetaData);
294295
assertThat(unwrappedImpl).isInstanceOf(BigQueryResultSetMetadata.class);
295296

296-
SQLException e =
297-
assertThrows(SQLException.class, () -> resultSetMetaData.unwrap(java.sql.Connection.class));
297+
BigQueryJdbcException e =
298+
assertThrows(
299+
BigQueryJdbcException.class, () -> resultSetMetaData.unwrap(java.sql.Connection.class));
298300
assertThat((Throwable) e).hasMessageThat().contains("Cannot unwrap to java.sql.Connection");
299301
}
300302

0 commit comments

Comments
 (0)