@@ -191,9 +191,12 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
191191 } else if (parts .length == 1 ) {
192192 this .defaultDataset = DatasetId .of (parts [0 ]);
193193 } else {
194- throw new IllegalArgumentException (
195- "DefaultDataset format is invalid. Supported options are datasetId or"
196- + " projectId.datasetId" );
194+ IllegalArgumentException ex =
195+ new IllegalArgumentException (
196+ "DefaultDataset format is invalid. Supported options are datasetId or"
197+ + " projectId.datasetId" );
198+ LOG .severe (ex , ex .getMessage ());
199+ throw ex ;
197200 }
198201 }
199202 this .location = ds .getLocation ();
@@ -267,6 +270,7 @@ String getLibraryVersion(Class<?> libraryClass) {
267270 version = props .getProperty ("version.jdbc" );
268271 }
269272 } catch (IOException e ) {
273+ LOG .severe (e , "Failed to load dependencies.properties" );
270274 return DEFAULT_VERSION ;
271275 }
272276
@@ -297,8 +301,10 @@ BigQueryReadClient getBigQueryReadClient() {
297301 this .bigQueryReadClient = getBigQueryReadClientConnection ();
298302 }
299303 } catch (IOException e ) {
300- LOG .severe (e , "Failed to initialize BigQueryReadClient" );
301- throw new BigQueryJdbcRuntimeException (e );
304+ BigQueryJdbcRuntimeException ex =
305+ new BigQueryJdbcRuntimeException ("Failed to initialize BigQueryReadClient" , e );
306+ LOG .severe (ex , ex .getMessage ());
307+ throw ex ;
302308 }
303309 return this .bigQueryReadClient ;
304310 }
@@ -309,8 +315,10 @@ BigQueryWriteClient getBigQueryWriteClient() {
309315 this .bigQueryWriteClient = getBigQueryWriteClientConnection ();
310316 }
311317 } catch (IOException e ) {
312- LOG .severe (e , "Failed to initialize BigQueryWriteClient" );
313- throw new BigQueryJdbcRuntimeException (e );
318+ BigQueryJdbcRuntimeException ex =
319+ new BigQueryJdbcRuntimeException ("Failed to initialize BigQueryWriteClient" , e );
320+ LOG .severe (ex , ex .getMessage ());
321+ throw ex ;
314322 }
315323 return this .bigQueryWriteClient ;
316324 }
@@ -357,7 +365,10 @@ public Statement createStatement(int resultSetType, int resultSetConcurrency)
357365 checkClosed ();
358366 if (resultSetType != ResultSet .TYPE_FORWARD_ONLY
359367 || resultSetConcurrency != ResultSet .CONCUR_READ_ONLY ) {
360- throw new BigQueryJdbcSqlFeatureNotSupportedException ("Unsupported createStatement feature." );
368+ BigQueryJdbcSqlFeatureNotSupportedException ex =
369+ new BigQueryJdbcSqlFeatureNotSupportedException ("Unsupported createStatement feature." );
370+ LOG .severe (ex , ex .getMessage ());
371+ throw ex ;
361372 }
362373 return createStatement ();
363374 }
@@ -383,7 +394,10 @@ public Statement createStatement(
383394 if (resultSetType != ResultSet .TYPE_FORWARD_ONLY
384395 || resultSetConcurrency != ResultSet .CONCUR_READ_ONLY
385396 || resultSetHoldability != ResultSet .CLOSE_CURSORS_AT_COMMIT ) {
386- throw new BigQueryJdbcSqlFeatureNotSupportedException ("Unsupported createStatement feature" );
397+ BigQueryJdbcSqlFeatureNotSupportedException ex =
398+ new BigQueryJdbcSqlFeatureNotSupportedException ("Unsupported createStatement feature" );
399+ LOG .severe (ex , ex .getMessage ());
400+ throw ex ;
387401 }
388402 return createStatement ();
389403 }
@@ -400,14 +414,20 @@ public PreparedStatement prepareStatement(String sql) throws SQLException {
400414 @ Override
401415 public PreparedStatement prepareStatement (String sql , int autoGeneratedKeys ) throws SQLException {
402416 if (autoGeneratedKeys != Statement .NO_GENERATED_KEYS ) {
403- throw new BigQueryJdbcSqlFeatureNotSupportedException ("autoGeneratedKeys is not supported" );
417+ BigQueryJdbcSqlFeatureNotSupportedException ex =
418+ new BigQueryJdbcSqlFeatureNotSupportedException ("autoGeneratedKeys is not supported" );
419+ LOG .severe (ex , ex .getMessage ());
420+ throw ex ;
404421 }
405422 return prepareStatement (sql );
406423 }
407424
408425 @ Override
409426 public PreparedStatement prepareStatement (String sql , int [] columnIndexes ) throws SQLException {
410- throw new BigQueryJdbcSqlFeatureNotSupportedException ("autoGeneratedKeys is not supported" );
427+ BigQueryJdbcSqlFeatureNotSupportedException ex =
428+ new BigQueryJdbcSqlFeatureNotSupportedException ("autoGeneratedKeys is not supported" );
429+ LOG .severe (ex , ex .getMessage ());
430+ throw ex ;
411431 }
412432
413433 @ Override
@@ -417,7 +437,10 @@ public PreparedStatement prepareStatement(
417437 if (resultSetType != ResultSet .TYPE_FORWARD_ONLY
418438 || resultSetConcurrency != ResultSet .CONCUR_READ_ONLY
419439 || resultSetHoldability != ResultSet .CLOSE_CURSORS_AT_COMMIT ) {
420- throw new BigQueryJdbcSqlFeatureNotSupportedException ("Unsupported prepareStatement feature" );
440+ BigQueryJdbcSqlFeatureNotSupportedException ex =
441+ new BigQueryJdbcSqlFeatureNotSupportedException ("Unsupported prepareStatement feature" );
442+ LOG .severe (ex , ex .getMessage ());
443+ throw ex ;
421444 }
422445 return prepareStatement (sql );
423446 }
@@ -428,7 +451,10 @@ public PreparedStatement prepareStatement(String sql, int resultSetType, int res
428451 LOG .finest ("++enter++" );
429452 if (resultSetType != ResultSet .TYPE_FORWARD_ONLY
430453 || resultSetConcurrency != ResultSet .CONCUR_READ_ONLY ) {
431- throw new BigQueryJdbcSqlFeatureNotSupportedException ("Unsupported prepareStatement feature" );
454+ BigQueryJdbcSqlFeatureNotSupportedException ex =
455+ new BigQueryJdbcSqlFeatureNotSupportedException ("Unsupported prepareStatement feature" );
456+ LOG .severe (ex , ex .getMessage ());
457+ throw ex ;
432458 }
433459 return prepareStatement (sql );
434460 }
@@ -538,8 +564,10 @@ private void beginTransaction() {
538564 }
539565 this .transactionStarted = true ;
540566 } catch (InterruptedException ex ) {
541- LOG .severe (ex , "Failed to begin transaction" );
542- throw new BigQueryJdbcRuntimeException (ex );
567+ BigQueryJdbcRuntimeException e =
568+ new BigQueryJdbcRuntimeException ("Failed to begin transaction" , ex );
569+ LOG .severe (e , e .getMessage ());
570+ throw e ;
543571 }
544572 }
545573
@@ -646,7 +674,9 @@ Long getListenerPoolSize() {
646674 @ Override
647675 public boolean isValid (int timeout ) throws SQLException {
648676 if (timeout < 0 ) {
649- throw new BigQueryJdbcException ("timeout must be >= 0" );
677+ BigQueryJdbcException ex = new BigQueryJdbcException ("timeout must be >= 0" );
678+ LOG .severe (ex , ex .getMessage ());
679+ throw ex ;
650680 }
651681 if (!isClosed ()) {
652682 try (Statement statement = createStatement ();
@@ -776,8 +806,9 @@ public void rollback() throws SQLException {
776806 beginTransaction ();
777807 }
778808 } catch (InterruptedException | BigQueryException ex ) {
779- LOG .severe (ex , "Failed to rollback transaction" );
780- throw new BigQueryJdbcException (ex );
809+ BigQueryJdbcException e = new BigQueryJdbcException ("Failed to rollback transaction" , ex );
810+ LOG .severe (e , e .getMessage ());
811+ throw e ;
781812 }
782813 }
783814
@@ -852,11 +883,15 @@ public void close() throws SQLException {
852883 }
853884 this .openStatements .clear ();
854885 } catch (ConcurrentModificationException ex ) {
855- LOG .severe (ex , "Concurrent modification during close" );
856- throw new BigQueryJdbcException (ex );
886+ BigQueryJdbcException e =
887+ new BigQueryJdbcException ("Concurrent modification during close" , ex );
888+ LOG .severe (e , e .getMessage ());
889+ throw e ;
857890 } catch (InterruptedException e ) {
858- LOG .severe (e , "Interrupted during close" );
859- throw new BigQueryJdbcRuntimeException (e );
891+ BigQueryJdbcRuntimeException ex =
892+ new BigQueryJdbcRuntimeException ("Interrupted during close" , e );
893+ LOG .severe (ex , ex .getMessage ());
894+ throw ex ;
860895 }
861896 this .isClosed = true ;
862897 }
@@ -868,14 +903,20 @@ public boolean isClosed() {
868903
869904 private void checkClosed () {
870905 if (isClosed ()) {
871- throw new IllegalStateException ("This " + getClass ().getName () + " has been closed" );
906+ IllegalStateException ex =
907+ new IllegalStateException ("This " + getClass ().getName () + " has been closed" );
908+ LOG .severe (ex , ex .getMessage ());
909+ throw ex ;
872910 }
873911 }
874912
875913 private void checkIfEnabledSession (String methodName ) {
876914 if (!this .enableSession ) {
877- throw new IllegalStateException (
878- String .format ("Session needs to be enabled to use %s method." , methodName ));
915+ IllegalStateException ex =
916+ new IllegalStateException (
917+ String .format ("Session needs to be enabled to use %s method." , methodName ));
918+ LOG .severe (ex , ex .getMessage ());
919+ throw ex ;
879920 }
880921 }
881922
@@ -1060,7 +1101,10 @@ private void commitTransaction() {
10601101 commitJob .waitFor ();
10611102 this .transactionStarted = false ;
10621103 } catch (InterruptedException ex ) {
1063- throw new BigQueryJdbcRuntimeException (ex );
1104+ BigQueryJdbcRuntimeException e =
1105+ new BigQueryJdbcRuntimeException ("Interrupted during commitTransaction" , ex );
1106+ LOG .severe (e , e .getMessage ());
1107+ throw e ;
10641108 }
10651109 }
10661110
0 commit comments