oracle.jdbc.ReadTimeout and Socket read timed out

2019-08-10 19:29发布

问题:

Sometimes I'm getting the below error on my application running on jboss 7 with DBCP . I would like to understand : does it means oracle.jdbc.ReadTimeout is configure on my application or not ? how can I check what is oracle.jdbc.ReadTimeout value ?

Caused by: oracle.net.ns.NetException: Socket read timed out
            at oracle.net.ns.Packet.receive(Packet.java:320)
            at oracle.net.ns.DataPacket.receive(DataPacket.java:103)
            at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:230)
            at oracle.net.ns.NetInputStream.read(NetInputStream.java:175)
            at oracle.net.ns.NetInputStream.read(NetInputStream.java:100)
            at oracle.net.ns.NetInputStream.read(NetInputStream.java:85)
            at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:122)
            at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:78)
            at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1179)
            at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1155)
            at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:279)
            at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
            at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)

回答1:

The answer to your first question is yes. If you're seeing this exception, then the read timeout property must be set. By default there is no read timeout and so you would never see this exception.

The answer to your second question is 'it depends'. The read timeout can be set as a system property with -D in the command line. It can also be set through a DataSource property. Try to grep for oracle.jdbc.ReadTimeout in your scripts.