Reputation: 135
I am trying to research this issue on the following two errors connecting to Oracle DBs:
java.sql.SQLException
: Io exception: Socket read timed outMy understanding:
java.sql.SQLException
: Io exception: Socket read timed out : This is a case where the connection was made successfully but for some reason the socket/data was empty and eventually it timed-out because no data was available.Is it possible to replicate the above errors in a local Oracle DB env ? What are the steps ?
I appreciate you taking the time to respond.
Thanks.
Upvotes: 10
Views: 94464
Reputation: 38930
Your understanding on closed connection is right. reason for closed connection: External devices such as firewall, network devices, and remote database listeners can force network connections to close after a period of inactivity
ReadTimeOut will happen even on active connections. If a query or procedure is taking lot of time, you will get read time out exception.
- Closed Connection : Shutdown the database listener when database is running
- ReadTimedOut : Add sleep in procedure for more than 10 minutes and call that procedure from application
Replication of Socket read time out error in Oracle DB env:
setNetworkTimeout
for SQL connection // for example sake, set timeout as 120 secondsCall a database procedure from java and sleep in that procedure for time more than setNetworkTimeout
dbms_lock.sleep(125); -- sleeps for 125 seconds
Since procedure is not returning with-in 120 seconds due to 125 seconds sleep, java will throw socket read time out in above scenario.
Upvotes: 5
Reputation: 100
I have just started working with the java.sql.* package, but here is what I understand. A closed connection is an error that occurs and the DB session closes, but no error handling is done so that is the end of it. With java.SQException you can manage this error (use a throws clause) and print it out or do other error handling methods.
Here is a link from Oracle about Exceptions and how to handle them.
Hope this helps.
Upvotes: 0