Using ComboPooledDataSource as a db connection pool. It seems like connections are being opened to frequently against my database. All of the queries use a try-with-resources block when opening the connection. My hypothesis is that using the try-with-resources block when opening the connection is also auto closing it, so the connection with my DB never gets re-used. Code in question looks like:
try (Connection conn = comboPooledDataSource.getConnection()) {
// ... do stuff with conn
}
I'm thinking that instead of using the try with resources it should just be a regular try statement and should not close the connection... leave that up to the ComboPooledDataSource. It would look like:
try {
Connection conn = comboPooledDataSource.getConnection()
// ... do stuff with conn but don't close it
}