In our Oracle 11g R2 development database, we noticed that connections opened through our Java application using BasicDataSource remain open indefinitely. Ideally, we would like each application instance to have up to 5 simultaneous database sessions, however if the session is inactive for more than 60 seconds, the session should close to reduce the memory impact on the database.
Using the following code to configure our underlying data source, I can notice that we are under the ceiling of 5 database sessions, but we do not seem to clear inactive sessions:
BasicDataSource ds = new BasicDataSource();
ds.setUrl(getUrlAsString());
ds.setDriverClassName("oracle.jdbc.driver.OracleDriver");
ds.setUsername(getClientOracleUserAsString());
ds.setPassword(getClientOraclePasswordAsString());
ds.setMinIdle(0);
ds.setMaxIdle(5);
ds.setMinEvictableIdleTimeMillis(60000);
source
share