AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Oracle JDBC hangs on socket read

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
Amos B
Guest





PostPosted: Thu Oct 19, 2006 9:15 pm    Post subject: Oracle JDBC hangs on socket read Reply with quote



Hi,
I've run into this issue multiple times with no solution yet.
For different reasons, the connection between the java application and
the oracle server may drop. This can happen because the network
interface was stopped and started or because of a firewall.

The problem is that when the network connection drops for the above
reasons, the jdbc connections can get stuck while trying to read from a
socket. These connection hang forever. Highly annoying.

Is there anyway to configure the timeout value of the socket used by
the JDBC driver?


Here is an example stack trace:

at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at oracle.net.ns.Packet.receive(Unknown Source)
at oracle.net.ns.DataPacket.receive(Unknown Source)
at oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:971)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:941)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:432)
at
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at
oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:543)
at
oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:915)
at
oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:452)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:986)
at
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2888)
at
oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2929)
- locked <0x5b9005d8> (a oracle.jdbc.driver.T4CPreparedStatement)
- locked <0x5c246760> (a oracle.jdbc.driver.T4CConnection)
Back to top
joeNOSPAM@BEA.com
Guest





PostPosted: Fri Oct 20, 2006 12:22 am    Post subject: Re: Oracle JDBC hangs on socket read Reply with quote



On Oct 19, 9:15 am, "Amos B" <amos...@gmail.com> wrote:
Quote:
Hi,
I've run into this issue multiple times with no solution yet.
For different reasons, the connection between the java application and
the oracle server may drop. This can happen because the network
interface was stopped and started or because of a firewall.

The problem is that when the network connection drops for the above
reasons, the jdbc connections can get stuck while trying to read from a
socket. These connection hang forever. Highly annoying.

Is there anyway to configure the timeout value of the socket used by
the JDBC driver?

Here is an example stack trace:

at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at oracle.net.ns.Packet.receive(Unknown Source)
at oracle.net.ns.DataPacket.receive(Unknown Source)
at oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.net.ns.NetInputStream.read(Unknown Source)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:971)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:941)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:432)
at
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:1­81)
at
oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStateme­nt.java:543)
at
oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement..j­ava:915)
at
oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedS­tatement.java:452)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.jav­a:986)
at
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedSt­atement.java:2888)
at
oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedState­ment.java:2929)
- locked <0x5b9005d8> (a oracle.jdbc.driver.T4CPreparedStatement)
- locked <0x5c246760> (a oracle.jdbc.driver.T4CConnection)

Hi. You have some options:

0 - Have you tried calling Statement.setQueryTimeout()?

1 - Alter your OS's TCP timeout so it notifies the socket
sooner than the default TCP timout (usually 5 minutes).

If your thread hangs much longer, then it's a serious firewall
problem, where it keeps the client-side socket open, but
simply stops passing stuff to it or from it...

2 - If you get Oracle's latest driver (10.2) and decompile it to
find some undocumented methods/interfaces. There is an
abort() method on the connection. If you cast your connection
to the right class/interface you can call that method, which
will close the connection/socket without being blocked by
the hanging thread, and you can clear it up that way.

Joe Weinstein at BEA
Back to top
Amos B
Guest





PostPosted: Fri Oct 20, 2006 6:55 pm    Post subject: Re: Oracle JDBC hangs on socket read Reply with quote



Thanks!!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.