Oracle JDBC slow connection on some virtual server

This issue is found on Oracle JDBC driver 11.2.x.

  • Environment : Linux virtual server, Oracle JDBC driver 11.2.x
  • Issue : Oracle connection takes long time or occurs timeout error
  • Cause : Oracle JDBC driver, when it connect to database server, calls java.security.SecureRandom class. SecureRandom uses /dev/random on Linux or Unix server. /dev/random pseudo device uses some noises from keyboard, mouse or some device drivers to make sufficient entropy. But virtual server usually don’t get enough noises within short time. Therefore, SecureRandom can be slow or hang in generating random value. (This is not a bug. Refer to the following Javadoc)
  • Workaround : Use /dev/urandom instead of /dev/random with the following option
-Djava.security.egd=file:/dev/../dev/urandom
or
-Djava.security.egd=file:/dev/./urandom
or
-Djava.security.egd=file:///dev/urandom

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.