dcsimg
A problem about releasing DB connection resources
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Motor_Qian
Posted On:   Thursday, April 19, 2001 06:34 AM

I made a class called PoolClient, code stub is listed below: public class PoolClient { // The JDBC Connection object public Connection con = null; // The JDBC Statement object public Statement stmt = null; // The JDBC ResultSet object public ResultSet rs = null; public void PoolClient { //Initialize the connection //........ } public void finalize() throws Exception { System.out.println("PoolClient finalized!"); this.close(); } public void close() throws Exception { if (stmt!=null) stmt.close(); if (con!=null) con.close(); if (rs!=null) rs.close();    More>>

I made a class called PoolClient, code stub is listed below:

public class PoolClient
{
// The JDBC Connection object
public Connection con = null;

// The JDBC Statement object
public Statement stmt = null;

// The JDBC ResultSet object
public ResultSet rs = null;

public void PoolClient
{
//Initialize the connection
//........
}

public void finalize() throws Exception
{
System.out.println("PoolClient finalized!");
this.close();
}
public void close() throws Exception
{
if (stmt!=null) stmt.close();
if (con!=null) con.close();
if (rs!=null) rs.close();

}

public ResultSet query(String sql)
{
stmt = con.createStatement();
stmt.execute(sql);
rs = stmt.getResultSet();
return rs;

}
}

And it seems to work perfectly at the beginning. However, things become out of control. The weblogic server, on which our JDBC pool lays, often refuses to response, and logs some not understandable information. The situation looks like resource consuming. And I checked the code above, the finalize() seems never invoked. I try the System.gc() outside of the class, and the finalize() is invoked, but some other situation occur "T3 connection disconnected by a thread other than the thread which created it".
My god, I don't know if I made myself clear. But please help me.
Thank you!

   <<Less
About | Sitemap | Contact