Menu

#264 Connection.close() does not release TCP/IP port

None
closed-fixed
jdbc (175)
1
2017-03-02
2003-05-12
TomK
No

When using Connection.close() to close a connection
with a HSQLDB server, the TCP/IP connection is not
closed until the client JVM is terminated.

This can easily be checked using netstat under Windows.

Open a connection (Keep the client running)
-> connection to port 9001 is visible in netstat /a

Close the connection (keep the client JVM running!)
-> connection to port 9001 is still visible in netstat /a
Any attempt to issue a statement using the Connection
inside the Java client will result in an error

close client JVM
-> connection disappears

Discussion

  • Anonymous

    Anonymous - 2003-05-13
    • assigned_to: nobody --> boucherb
    • status: open --> open-accepted
     
  • Anonymous

    Anonymous - 2003-05-13

    Logged In: YES
    user_id=199381

    Thanks. Checked it and sure enough, close does no
    work toward closing the socket, if there is one.

    The patch is simple (I think):

    public void close() throws SQLException {

    if (Trace.TRACE) {
    Trace.trace();
    }

    if (iType == INTERNAL) {
    return;
    }

    if (bClosed) {
    return;
    }

    // FIXME:
    // closeStandalone() should only get called for
    STANDALONE
    // calling close on an internal connection should
    do nothing
    // Internal connections should not execute
    DISCONNECT or set
    // bClosed true
    // Only one instance of internal connection should
    exist for
    // each Session, and it should be open for the life
    of
    // its Session
    // boucherb@users 20020409
    // fredt - patch 1.7.1 - implemented the above
    if (iType == STANDALONE) {
    closeStandalone();
    } else {
    execute("DISCONNECT");
    }

    // ------- patch --------
    if (sSocket != null) {
    try {
    sSocket.close();
    } catch (Exception e) {
    if (Trace.TRACE) {
    Trace.trace(e);
    }
    }
    sSocket = null;
    }
    //--

    bClosed = true;

     
  • Anonymous

    Anonymous - 2003-05-15

    Logged In: YES
    user_id=199381

    Oops:

    // ------- patch --------
    if (sSocket != null) {
    try {
    sSocket.close();
    } catch (Exception e) {
    if (Trace.TRACE) {
    Trace.trace(e.toString());
    }
    }
    sSocket = null;
    }
    //--

     
  • Anonymous

    Anonymous - 2003-06-17

    Logged In: YES
    user_id=199381

    commited to cvs in hsqldb-dev branch jdbcConnection,
    revision 1.20

    http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/hsqldb/hsqldb-
    dev/src/org/hsqldb/jdbcConnection.java.diff?r1=1.19&r2=1.20

     
  • Anonymous

    Anonymous - 2003-06-17
    • priority: 5 --> 1
     
  • Anonymous

    Anonymous - 2003-08-29
    • status: open-accepted --> closed-fixed
     

Log in to post a comment.