[jcifs] jTDS + jCIFS works!

David D. Kilzer ddkilzer at kilzer.net
Wed Jul 21 20:18:51 GMT 2004


On Tue, Jul 20, 2004 at 12:59:43AM -0400, Michael B Allen wrote:

> On Mon, 19 Jul 2004 23:23:35 -0500, David D. Kilzer wrote:
> 
> > I do have one more question about named pipes, though.  Is there a way
> > to set a connection timeout for them using the current API, or does it
> > not make any sense to do that?
> 
> Even though Java's IO model doesn't really support the concept of a
> timeout on a read, if the behavior of TDS is observed to use transaction
> timeouts that might be necessary to properly emulate the protocol. We
> don't currently support transaction timeouts because there is no
> generic interface for transactions but we might be able to expose it
> in TransactNamedPipeInputStream or somewhere else. If you have a packet
> capture that shows timeouts being used in some fashion and for practical
> purposes think it's better to emulate that behavior then I'll look at
> the issue closer.

Here's the situation I'm trying to resolve:  The jTDS driver must
implement java.sql.Statement.setQueryTimeout(int seconds).

The current implementation for connecting to SQL Server via TCP/IP is to
set java.net.Socket.setSoTimeout(seconds * 1000).  When a
SocketTimeoutException (which extends InterruptedIOException) is thrown,
jTDS catches it and cancels the connection.

There is a test method called SAfeTest.testCancel0002() that tests
Statement.setQueryTimeout() by creating an explicit deadlock condition
in the datbase.  It works fine for a TCP/IP connection to SQL Server
2000.

However, when using a named pipe with jCIFS to SQL Server 6.5, I am
unable to set the SmbTransport.SO_TIMEOUT or RESPONSE_TIMEOUT values
correctly using code like the following.  (My guess is that the
SmbTransport objects have already been created such that setting these
values in the Config object doesn't do anything.)

  Config.setProperty("jcifs.smb.client.soTimeout", String.valueOf(timeout));
  Config.setProperty("jcifs.smb.client.responseTimeout", String.valueOf(timeout));

And even if I could set the values, the default values (which are
RESPONSE_TIMEOUT = 0 and SO_TIMEOUT = 15000 when the above test is run)
cause the connection to NEVER timeout.  The SmbTransport.run() method
gets stuck in an infinite loop, catching an InterruptedIOException at
line 471 of SmbTransport.run() and continuing to run the while loop
infinitely, while waiting for a 'Read AndX Response' that will never
arrive.  (I can easily send a packet trace if desired.)

I need a way for a named pipe connection to timeout so that the
Statement.setQueryTimeout() feature may be implemented properly.  Any
ideas?

Dave


More information about the jcifs mailing list