How are others dynamically resetting/resizing their database connection pools
when necessary?
Background:
I am running into some issues with how we manage datasources due to changes in
Tomcat/commons-dbcp.
We are just now beginning to move some of our applications to Tomcat 7.0.21
from Tomcat 6.0.20. We have written some tools that allow us to reset
datasources that have worked great with 6.0.20 ( closes all unused connections
and creates a new pool ). We also have tools that allow us to dynamically
resize connection pools, on the fly. Both of these depend on JMX.
When we used the JMX .close() method on the BasicDataSource under Tomcat 7, the
next time the application makes the request for a connection it receives a...
throw new SQLException("Data source is closed");
It looks like some changes were made to commons-dbcp which set a private member
variable called "closed" when you close a BasicDataSource. Any time the
createDataSource() code is called it check this new member variable and if
closed=true, it throws this error.
Next, I looked at the new datasource org.apache.tomcat.jdbc.pool.DataSource. I
have not found any methods to close/reset the pools and the JMX attributes are
readonly. This prevents us both from resetting and resizing our connection
pools.
So far, my options point to making changes to the BasicDataSource to provide a
way to set closed=false or make the private method below public with a change
to set closed=false.
/**
* Not used currently
*/
private void restart() { // change to public -bth
try {
close();
closed = false; // new line added here -bth
} catch (SQLException e) {
log("Could not restart DataSource, cause: " + e.getMessage());
}
}
Thanks,
Brooke Hedrick
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]