Dear Experts,
I'm having an issue closing DB connections. I've written a java driver class in which I directly access DB tables (no ADF BC used, just plain old java ). The structure is as follows:
public String getCertainInfo(int key)
{
ResultSet rs = null;
PreparedStatement pst = null;
String name ="";
try
{
Connection conn = null;
conn = instance.getConnection();
String sql = null;
sql = "select * from TABLE where KEY=?";
pst = instance.getConnection().prepareStatement(sql);
pst.setInt(1, Integer.parseInt(key));
rs = pst.executeQuery();
if (rs != null && rs.next()) {
name = rs.getString(3);
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try {
if (rs != null) {
rs.close();
}
if (pst != null) {
pst.close();
}
if (instance.getConnection() != null) {
instance.getConnection().close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return name;
}
The issue is when I consume all the connection count that the data source allows ( default of initial pool capacity = 1, and maximum pool size of 15 ), I'm getting the error:
"weblogic.jdbc.extensions.PoolLimitSQLException: weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool MyDS to allocate to applications, please increase the size of the pool and retry.."
where MyDS is the data source that I created on Weblogic. This is a clear indication that the connections I'm using are not being closed/released properly, Can anyone tell me what's wrong here? Thanks in advance.
Best Regards,
JDeveloper 12.1.3.0.0
Java 1.7.0_45