A simple java program that connects to a database server using JDBC has a runtime that changes everywhere.

I have a very simple java program (see below) on my application server that successfully connects to the Oracle 11.2 database on the database server (both servers are Linux CentOS) using the thin JDBC driver from Oracle.

As you can see from the setURL command in the Java code below, I configured the application and database server so that they sit next to each other and they are on the same network (a cross-cable connected to each other), so there is no network traffic to these (development) boxes except my code.

The problem is that the execution time varies greatly. If I ran it 5 times, it (seemingly by accident) could take 0.01 seconds, or 10 seconds, or 50 seconds, or more minutes to complete. If it takes a minute (approximately), the program will not be completed, but instead the error shown below will be shown.

Any ideas what can be done here?

--------error returned when execution take more than about 1 minute-------
gn@host7 [~/fd]# java -cp ./ojdbc6_g.jar:. J
Exception in thread "main" java.sql.SQLRecoverableException: IO Error: Connection reset
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:494)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:547)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:225)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:29)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:556)
at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:454)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:328)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:233)
at J.main(J.java: line 16)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at oracle.net.ns.DataPacket.send(DataPacket.java:219)
at oracle.net.ns.NetOutputStream.flush(NetOutputStream.java:208)
at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:224)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:172)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:97)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:82)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:120)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:76)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1158)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1134)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:307)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:199)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:365)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:812)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
... 8 more

Java code for: J.java:

import java.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.OracleDataSource;

class J {

    public static void main(String args[]) throws SQLException {
    Connection conn;
    // connect to database
    OracleDataSource ds = new OracleDataSource();
    ds.setURL("jdbc:oracle:thin:hr/hrpwd@192.168.0.1:1973:mySID");
    conn = ds.getConnection();

    // create Oracle DatabaseMetaData object
    DatabaseMetaData meta = conn.getMetaData();
    // show database version
    System.out.println("Database version is " + meta.getDriverVersion());

    if ( conn != null ) {
      try { conn.close(); } catch ( Exception ex ) {}
      conn = null;
    }
    } 
}

UPDATE 1:

This looks like a potential error:

http://www.usn-it.de/index.php/2009/02/20/oracle-11g-jdbc-driver-hangs-blocked-by-devrandom-entropy-pool-empty/

Does anyone know how to really implement the solution provided there (see paragraph 3 at the end - where can I find this -Djava.security.egd=file:///dev/urandomto change it?)

+5
source share
4 answers

The answer is as follows (from CentOS forums):

Try editing /etc/sysconfig/rngd to contain:

# Add extra options here
EXTRAOPTIONS="-r /dev/urandom"

Then "service rngd start". If that works, then "chkconfig rngd on" will start it at boot.

. :

http://www.linuxfromscratch.org/hints/downloads/files/entropy.txt

http://www.usn-it.de/index.php/2009/02/20/oracle-11g-jdbc-driver-hangs-blocked-by-devrandom-entropy-pool-empty/

https://www.centos.org/modules/newbb/viewtopic.php?topic_id=36209&start=0#forumpost156856

https://forums.oracle.com/forums/thread.jspa?messageID=3793101

+6

, , , , , . , , , , " reset". Oracle, -, ( , - ).

0

Debian /etc/default/rng-tools

HRNGDEVICE="/dev/urandom"
RNGDOPTIONS="-o /dev/random -t 1 -b"`

( Omnited)

0

We run the script from the shell. I included the string -Djava.security.egd=file:///dev/urandomas part of a java call. Here is our whole command line:

/usr/bin/java -Xms64m -Xmx1024m -Djava.security.egd=file:///dev/urandom -jar $1 $2 $PID
0
source

All Articles