Sybase JDBC driver problem

R

rkm

When I'm done using my connection to a Sybase database, I
call the conn.close() method, but it doesn't seem to clean
up the underlying physical connection. Eventually I use up
all the available connections and (assuming I don't kill my
program) the Sybase admin ends up having to close the db on
his side and reopening it.

Aside from keeping one connection open and using it forever
(my current solution which I don't like), what's the
solution to the problem of the resources not being cleaned
up? Do I need to call a finalizer method (I'm led to
believe that's a general no-no), or maybe invoke the garbage
collector? Is this a known bug in the jconn2 driver?

Rick
 
L

Lee Yeow Leong

Make sure you close your rs and statement as well.

rs.close();
stmt.close();
conn.close();
 
I

Ike

Are you cleaning up everything else prior to cleaning up the connection?
Something along the lines of:
public void finalize(){
// it is a good idea to release
// resources in a finally{} block
// in reverse-order of their creation
// if they are no-longer needed
try {
if ( rs != null ) { //first the resultset object
rs.close();
}
}catch( Exception ignored ) {}
try {
if ( statement != null ) { //then the statement
statement.close();
}
}catch( Exception ignored ) {}
try {
if ( conn != null ) { then the connection
conn.close();
}
} catch( Exception ignored ) {}
rs=null;
statement=null;
conn=null;
}

//Ike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top