JZ0T3: Read operation timed out
Hi! I'm trying to solve this problem for a while and actually I couldnt find the cause of the problem.
For some reason, deep inside the code of my application that error happends when I execute some inserts on the same Sybase table (they could be performed concurrently). I said "deep inside the code" since if I test a similar code, but outside the application (that is, just executing the inserts in a stand alone java main) the problem can't be reproduced.
The connection is obtained normally as follows:
*******
try {
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
}catch (ClassNotFoundException e) {
System.out.println("Oops!");
}
Connection conn = DriverManager.getConnection(url,user,psw);
conn.setAutoCommit(true);
*******
The driver been used is jconnect 4.5
Then, several inserts are performed:
*******
String exampleQuery = "INSERT INTO SampleTable (id) VALUES ("1")\nSELECT @@IDENTITY";
PreparedStatement stmt = conn.prepareStatement(exampleQuery);
ResultSet rs = stmt.executeQuery();
if (rs.next())
System.out.println(rs.getInt(1));
*******
Some of the query executions raise the following exception:
*******
java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0T3: Read operation timed out.
at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:485)
at com.sybase.jdbc2.tds.Tds.handleIOE(Tds.java:2961)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1796)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:201)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:182)
at com.sybase.jdbc2.jdbc.SybStatement.queryLoop(SybStatement.java:1455)
at com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:1440)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeQuery(SybPreparedStatement.java:70)
*******
I've just found a workarround to solve this problem: synchronizing the execution of the query. That seems to avoid concurrent insertion.
The funny thing is: when I extract the code from the application and execute it in a stand alone java main, even stressing with multiple threads executing batch inserts in a for clause, the problem NEVER happends.
Any tip is welcome since I actually don't know what to do. Thanks a lot, I hope anyone replies!!
Bye!