4

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?

user513951
  • 12,445
  • 7
  • 65
  • 82
Mohamed Fenni
  • 41
  • 1
  • 1
  • 6

2 Answers2

7

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:

  1. 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

  2. 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
Karim
  • 8,454
  • 3
  • 25
  • 33
-1

Connection reset usually happens when the connection between you app and the database gets disconnected for example network issue or resources that's required.

Check the following post it should give you an idea of what to check. SQLRecoverableException: I/O Exception: Connection reset

Community
  • 1
  • 1
Renier
  • 1,738
  • 3
  • 24
  • 51