Sybase JDBC driver problem

Discussion in 'Java' started by rkm, Jan 3, 2004.

  1. rkm

    rkm Guest

    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
     
    rkm, Jan 3, 2004
    #1
    1. Advertising

  2. Make sure you close your rs and statement as well.

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

    rkm wrote:
    > 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
    >
     
    Lee Yeow Leong, Jan 4, 2004
    #2
    1. Advertising

  3. rkm

    Ike Guest

    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

    "rkm" <> wrote in message
    news:...
    > 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
    >
     
    Ike, Jan 4, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Betty
    Replies:
    1
    Views:
    9,928
    Juha Laiho
    May 21, 2005
  2. davo_java
    Replies:
    1
    Views:
    798
    davo_java
    Jun 23, 2005
  3. Bruce
    Replies:
    4
    Views:
    791
    Bjorn Abelli
    Mar 25, 2006
  4. Replies:
    3
    Views:
    426
    Roedy Green
    May 17, 2008
  5. Lew
    Replies:
    0
    Views:
    550
Loading...

Share This Page