We have a java application that talks to oracle 11.2 using jdbc. We are using oracle-jdbc-7.jar
Created-By: 20.12-b01 (Sun Microsystems Inc.)
Implementation-Vendor: Oracle Corporation
Implementation-Title: JDBC
Implementation-Version: 12.1.0.1.0
We are also using Statement.setQueryTimeout()
However, every few days, the thread talking to oracle hangs while doing a ResultSet.next().
Code looks like this:
PreparedStatement ps = createPreparedStatement();
ps.setQueryTimeout(60);
while (true) {
ps.executeQuery();
//iterate over the ResultSet doing ResultSet.next() continuously
//do something with the ResultSet
//sleep for 1 second.
}
Threaddump:
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at oracle.net.ns.Packet.receive(Packet.java:311)
at oracle.net.ns.DataPacket.receive(DataPacket.java:105)
at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:305)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:249)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:171)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:89)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:123)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:79)
at oracle.jdbc.driver.T4CMAREngineStream.unmarshalUB1(T4CMAREngineStream.java:426)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:390)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:566)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215)
at oracle.jdbc.driver.T4CPreparedStatement.fetch(T4CPreparedStatement.java:1022)
at oracle.jdbc.driver.OracleStatement.fetchMoreRows(OracleStatement.java:3590)
at oracle.jdbc.driver.InsensitiveScrollableResultSet.fetchMoreRows(InsensitiveScrollableResultSet.java:1008)
at oracle.jdbc.driver.InsensitiveScrollableResultSet.absoluteInternal(InsensitiveScrollableResultSet.java:972)
at oracle.jdbc.driver.InsensitiveScrollableResultSet.next(InsensitiveScrollableResultSet.java:572)
- locked <0x00000000d0873738> (a oracle.jdbc.driver.T4CConnection)
Any ideas on resolving this would be appreciated?
We have tried using openjdk7 and oracle's JDK 7 but it did not help.
Thanks.
答案 0 :(得分:1)
尝试找到阻止会话。
SELECT
s.blocking_session,
s.sid,
s.serial#,
s.seconds_in_wait
FROM
v$session s
WHERE
blocking_session IS NOT NULL
如果是您的会话,那么您的查询可能需要优化。否则会引起其他问题。
P.S。 :我不是SQL专家