Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DB login timeout is twice time specified by DriverManager.setLoginTimeout

63 views
Skip to first unread message

JConnect user

unread,
Mar 31, 2003, 9:47:45 AM3/31/03
to
I have noticed that if I set a login timeout using
DriverManager.setLoginTimeout(int seconds), the JConnect driver does not
time out until roughly twice the number of seconds have elapsed. For
example, if I specify a timeout of 60 seconds, it times out after 124
seconds. If I specify a timeout of 30 seconds, it times out after 64
seconds, etc. I would like to be able to control the timeout accurately
becomes sometimes the Sybase server becomes stuck in a state where it
accepts a socket connection but sends no response (and the JDBC
connection attempt would hang forever if no timeout were specified).

I was able to simulate this scenario by having the JConnect driver
attempt to connect to a simple Java program that is listening on a port
and accepting socket conenctions. When the server program accepts a
connection, it sends no response via the OutputStream but does not close
the connection. Eventually the JConnect driver times out, but it is
twice the amount specified by setLoginTimeout.

Has anyone else noticed this problem? I am using JConnect 5.2 EBF 10838
and Java 1.2. Thanks!

odbcpse

unread,
Mar 31, 2003, 7:02:30 PM3/31/03
to JConnect user
I have not seen this problem. Perhaps you can open a Sybase Tech Support
case so this could be
investigated?

pv

NiklasHomeAddress

unread,
Apr 1, 2003, 2:49:36 PM4/1/03
to
Hi,

This is in a way a general issue of java .

Sybase have a Change request for this CR# 272457 ..... it is 2 option to get
this to work ...

1. This is a known SUN problem:
http://developer.java.sun.com/developer/bugParade/bugs/4110694.html
This has been a customer complaint for 4 years. There is a fix coming up in
JDK 1.4, but a JDBC driver would have to be modified to use this version of
JDK and higher. There is no time frame nor inclination of this at this time
for jconnect.

2. JDBC drivers (not only sybase jconnect that have this problem) in which
timeout does "work" incorporate some type of thread fix. Sybase can attempt
this as a Feature Request, since this is not a bug in jConnect. This is a
somewhat complicated change and there are reports that this leads to other
problems (like threads hanging around).


"JConnect user" <nos...@nospam.com> skrev i meddelandet
news:OYbTYT59CHA.329@forums-1-dub...

JConnect user

unread,
Apr 2, 2003, 2:19:42 PM4/2/03
to
Hi,

I read the description of Sun Bug Id 4110694, but I believe that is a
separate issue. That description is referring to the issue that prior to
JDK 1.4 one could not specify a socket connection timeout. I agree it is
important to be able to control that timeout as well. However, in my
case the socket is able to connect, but when the client tries to read
from the socket input stream, the server sends no response. I believe
this timeout is controlled through Socket.setSoTimeout(int timeout),
where timeout is the number of milliseconds to wait.

Based on my observations, it seems that if I specify a database login
timeout of n seconds via DriverManager.setLoginTimeout(n), JConnect
calls Socket.setSoTimeout(2*1000*n). Note that the parameter for
setLoginTimeout is in seconds, whereas the parameter for setSoTimeout is
in milliseconds. If I specify different login timeout, I notice the
timeout changes accordingly but it is always double what I have
specified. I believe a correct implementation should use
Socket.setSoTimeout(1000*n).

Thanks.

J

unread,
Apr 2, 2003, 9:19:51 PM4/2/03
to
On Wed, 02 Apr 2003 14:19:42 -0500, JConnect user <nos...@nospam.com>
wrote:

I think setLoginTimeout is meant to cover the whole process of getting
a connection (getConnection) which encompasses building a valid socket
endpoint and the required user login. Unfortunately, there are
separate events making up this non-atomic process: (1)connect
(including any name resolution) (2) on Sybase sending two login
packets one 512 bytes or so and second 95 bytes or so (3) reading the
response for the dataserver and negotiating any login properties.

In java these activities span two diffferent socket timeout
mechanisms, the connect(timeout) only available in 1.4 and up and the
SoTimeout for regular socket IO. I don't think the jdbc drivers
should use their own mechanisms for this as it get kludgy in a hurry.

I don't think jConnect is doing anything with the connect(timeout) for
reasons already stated. jConnect does set the SoTimeout but I think
there are two events which are timing out. I think when the
setLoginTimeout is really implemented then one could set the different
values and subtract any remaining time after getConnection, resetting
SoTimeout to the real desired value.

If you turn on the Sybase debugging you see two separate events which
are each timing out at the socket layer. See messages below. I'm not
sure this helps you all that much. This is all after the
socket.connect() ala your case. I think the setLoginTimeout is just
broken and you see it does two reads that each end up timing out.

(Thread[main,5,main]): java.sql.SQLException: JZ006: Caught
IOException: java.net.SocketTimeoutException: Read timed out
java.sql.SQLException: JZ006: Caught IOException:
java.net.SocketTimeoutException: Read timed out
at
com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:462)
at com.sybase.jdbc2.tds.Tds.handleIOE(Tds.java:2804)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1757)
at
com.sybase.jdbc2.tds.Tds.processLoginAckToken(Tds.java:2833)
at com.sybase.jdbc2.tds.Tds.doLogin(Tds.java:422)
at com.sybase.jdbc2.tds.Tds.login(Tds.java:349)
at
com.sybase.jdbc2.jdbc.SybConnection.tryLogin(SybConnection.java:210)
at
com.sybase.jdbc2.jdbc.SybConnection.regularConnect(SybConnection.java:190)
at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:169)
at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:122)
at com.sybase.jdbc2.jdbc.SybDriver.connect(SybDriver.java:175)
at
java.sql.DriverManager.getConnection(DriverManager.java:512)
at
java.sql.DriverManager.getConnection(DriverManager.java:140)
at CustomSybSocket.getConnectionSyb(CustomSybSocket.java:54)
at CustomSybSocket.main(CustomSybSocket.java:103)
(Thread[main,5,main]): java.sql.SQLException: JZ00L: Login failed.
Examine the SQLWarnings chained to this exception for the reason(s).
java.sql.SQLException: JZ00L: Login failed. Examine the SQLWarnings
chained to this exception for the reason(s).
at
com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:475)
at
com.sybase.jdbc2.tds.Tds.processLoginAckToken(Tds.java:2887)
at com.sybase.jdbc2.tds.Tds.doLogin(Tds.java:422)
at com.sybase.jdbc2.tds.Tds.login(Tds.java:349)
at
com.sybase.jdbc2.jdbc.SybConnection.tryLogin(SybConnection.java:210)
at
com.sybase.jdbc2.jdbc.SybConnection.regularConnect(SybConnection.java:190)
at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:169)
at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:122)
at com.sybase.jdbc2.jdbc.SybDriver.connect(SybDriver.java:175)
at
java.sql.DriverManager.getConnection(DriverManager.java:512)
at
java.sql.DriverManager.getConnection(DriverManager.java:140)
at CustomSybSocket.getConnectionSyb(CustomSybSocket.java:54)
at CustomSybSocket.main(CustomSybSocket.java:103)
com.sybase.jdbc2.timedio.OutStreamMgr(Thread[main,5,main]): Send
Ownership RELEASED. com.sybase.jdbc2.timedio.RequestObj@4741d6,
_state= 10, guestOf= null, context=
com.sybase.jdbc2.tds.TdsProtocolContext@e51060
Message : JZ00L: Login failed. Examine the SQLWarnings chained to
this exception for the reason(s).
Message : JZ006: Caught IOException: java.net.SocketTimeoutException:
Read timed out
Message : JZ006: Caught IOException: java.net.SocketTimeoutException:
Read timed out

0 new messages