"java.sql.SQLException: I/O Error: Connection reset" in linux server

java, linux, oracle

Solution

Answer took from oracle forum, here:

`java.security.SecureRandom` is a standard API provided by sun. Among various methods offered by this class `void nextBytes(byte[])`.

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 problem is two fold:

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")

Users upgrading to 11g can encounter this issue if the underlying OS is Linux which is running on a faulty hardware.

The cause of this has not yet been determined exactly. It could either be a problem in the hardware or the fact that for some reason the software cannot read from `dev/random`

a solution seems to add this setting to the jvm

-Djava.security.egd=file:/dev/./urandom

Problem

I have a java program which connect to oracle database sometimes it work and sometimes show me this error message : Exception in thread "main" java.sql.SQLRecoverableException: IO Error: Connection reset ``` at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:498) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528) ``` How i can solve this problem?

Original source

Related problems