Skip to content

Commit

Permalink
fix: Close database connection after test statement. (#15640) (#15689)
Browse files Browse the repository at this point in the history
* fix: Close database connection after test statement.
  • Loading branch information
jason-p-pickering authored Nov 16, 2023
1 parent 5b2831c commit 6be9257
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,12 @@ public static DataSource createC3p0DbPool(PoolConfig config)
}

public static void testConnection(DataSource dataSource) throws SQLException {
Connection conn = dataSource.getConnection();

try (Statement stmt = conn.createStatement()) {
try (Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement()) {
stmt.executeQuery("select 'connection_test' as connection_test;");
} catch (SQLException e) {
log.error(e.getMessage());
}
}
}

0 comments on commit 6be9257

Please sign in to comment.