Note that there are some explanatory texts on larger screens.

plurals
  1. POsimple java program connecting to database server using JDBC has execution time varying all over the place
    primarykey
    data
    text
    <p>I've got a very simple java program (J.java, see below) on my application server that successfully connects to an Oracle 11.2 database on a database server (both servers are Linux CentOS) using JDBC thin driver from Oracle. </p> <p>As you can see from the setURL command in the Java code below, I've configured the application and database servers to sit next to each other, and they're on the same network (cross-cable connected to each other), so there's no network traffic on these (development) boxes except my code. </p> <p>The problem is the execution time varies a lot. If I run it 5 times, it (seemingly randomly) could take 0.01 seconds, or 10 seconds, or 50 seconds, or over a minute to execute. If it takes over a minute (roughly), the program doesn't complete, but the error shown below is returned instead. </p> <p>Any ideas what could be going on here? </p> <pre><code>--------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.&lt;init&gt;(PhysicalConnection.java:547) at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(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 </code></pre> <p>The java code for: J.java is:</p> <pre><code>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; } } } </code></pre> <p>UPDATE 1:</p> <p>This looks like the potential culpret:</p> <p><a href="http://www.usn-it.de/index.php/2009/02/20/oracle-11g-jdbc-driver-hangs-blocked-by-devrandom-entropy-pool-empty/">http://www.usn-it.de/index.php/2009/02/20/oracle-11g-jdbc-driver-hangs-blocked-by-devrandom-entropy-pool-empty/</a></p> <p>Anyone know how to actually implement the solution provided there (see item 3 at end -- where would I find this <code>-Djava.security.egd=file:///dev/urandom</code> to change it?)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload