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
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;
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;
}
//--
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