others-How to solve connection reset exception when connecting with Oracle 11g with JDBC
1. The purpose of this post
Sometimes, when we execute sql via JDBC with Oracle 11g , we get this exception or error like this:
2. Solution
According to this post,there are two possible reasons you get this error:
java.security.SecureRandom is a standard API provided by sun. Among various methods offered by this class void nextBytes(byte[]) is one. This method is used for generating random bytes. Oracle 11g JDBC drivers use this API to generate random number during login. Users using Linux have been encountering SQLException(“Io exception: Connection reset”).
- The JVM tries to list all the files in the /tmp (or alternate tmp directory set by -Djava.io.tmpdir) when SecureRandom.nextBytes(byte[]) is invoked. If the number of files is large the method takes a long time to respond and hence cause the server to timeout
- The method void nextBytes(byte[]) uses /dev/random on Linux and on some machines which lack the random number generating hardware the operation slows down to the extent of bringing the whole login process to a halt. Ultimately the the user encounters SQLException(“Io exception:Connection reset”)
You can resolve the issue by adding this option to your command or system property:
2.1 Solution 1
2.2 Solution 2
2.3 My solution
I choose the first solution:
Run the command again , everything works fine now.