Oracle JDBC connection cannot be closed properly
843854Apr 1 2004 — edited Apr 30 2004I encountered a problem that Oracle JDBC connection cannot be close properly after "java.sql.SQLException: Io exception: Read timed out" is caught. The Oracle DB version is 8i.
The detailed scenario:
1. When my program performed a database insertion operation, it encountered a "java.sql.SQLException: Io exception: Read timed out"
2. Because the exception is a SQL exception, to handle the exception, my program first rolled back the database operation it just performed.
3. My program encountered a "java.sql.SQLException: Protocol violation" when it rolled back the operation
4. My program tried to close this particular problematic connection because I don't know if this connection is still valid or not
5. Again, my program encountered a "java.sql.SQLException: Protocol violation" when it tried to close the connection
6. Because my program failed to close the connection, it put this connection into a list so that a background thread was able to close it later
7. The background thread successfully (no exception is caught during the close) closed the connection which could not be closed properly previously
However, I found the number of connection increased and the old connection was not closed properly.
I found the interesting statement at http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#30_17)
What does "Protocol Violation" mean?
The Thin driver throws this exception when it reads something from the RDBMS that it did not expect. This means that the protocol engine in the Thin driver and the protocol engine in the RDBMS are out of synch. There is no way to recover from this error. The connection is dead. You should try to close it, but that will probably fail too.
If you get a reproducible test case that generates this error, please file a TAR with Oracle Global Support. Be sure to specify the exact version numbers of the JDBC driver and the RDBMS, including any patches
I think it explains why the connection cannot be closed properly.
My questions are:
1. If anyone encountered a similar case before? How do you work around the limitation of the Oracle JDBC Driver? I cannot let the number of connections keep increasing because eventually it will hit the maximum user sessions set by the server.
2. Is it necessary to close and re-open a connection if "java.sql.SQLException: Io exception: Read timed out" is caught?
Thanks in advance. Any suggestion or experience sharing is appreciated.