@@ -1743,30 +1743,34 @@ public void testValidDestinationTableSavesQueriesWithStandardSQL() throws SQLExc
17431743 public void testDestinationTableAndDestinationDatasetThatDoesNotExistsCreates ()
17441744 throws SQLException {
17451745 // setup
1746+ String largeResultDataset = ITBase .getUniqueDatasetName ("FakeDataset" );
17461747 String connection_uri =
1747- ITBigQueryJDBCTest .connection_uri
1748- + "QueryDialect=BIG_QUERY;"
1749- + "AllowLargeResults=1;"
1750- + "LargeResultTable=FakeTable;"
1751- + "LargeResultDataset=FakeDataset;" ;
1748+ String .format (
1749+ ITBigQueryJDBCTest .connection_uri
1750+ + "QueryDialect=BIG_QUERY;"
1751+ + "AllowLargeResults=1;"
1752+ + "LargeResultTable=FakeTable;"
1753+ + "LargeResultDataset=%s;" ,
1754+ largeResultDataset );
17521755 String selectLegacyQuery =
17531756 "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 200;" ;
17541757 Driver driver = BigQueryDriver .getRegisteredDriver ();
1755- Connection connection = driver .connect (connection_uri , new Properties ());
1756- Statement statement = connection .createStatement ();
1757-
1758- // act
1759- ResultSet resultSet = statement .executeQuery (selectLegacyQuery );
1758+ try (Connection connection = driver .connect (connection_uri , new Properties ())) {
1759+ Statement statement = connection .createStatement ();
17601760
1761- // assertion
1762- assertNotNull (resultSet );
1763- String separateQuery = "SELECT * FROM FakeDataset.FakeTable;" ;
1764- boolean result = bigQueryStatement .execute (separateQuery );
1765- assertTrue (result );
1761+ // act
1762+ ResultSet resultSet = statement .executeQuery (selectLegacyQuery );
17661763
1767- // clean up
1768- bigQueryStatement .execute ("DROP SCHEMA FakeDataset CASCADE;" );
1769- connection .close ();
1764+ // assertion
1765+ assertNotNull (resultSet );
1766+ String separateQuery = String .format ("SELECT * FROM %s.FakeTable;" , largeResultDataset );
1767+ boolean result = bigQueryStatement .execute (separateQuery );
1768+ assertTrue (result );
1769+ } finally {
1770+ // clean up
1771+ bigQueryStatement .execute (
1772+ String .format ("DROP SCHEMA IF EXISTS %s CASCADE;" , largeResultDataset ));
1773+ }
17701774 }
17711775
17721776 @ Test
0 commit comments