4 Replies Latest reply on Aug 12, 2010 11:21 AM by Andy Klock

    java.sql.SQLException: Io exception: Connection reset

    790746

      Hi all,

      I am using Jdev 10g (version 10.1.3.0.4.3673) and created a Java class that connects to a DB of version:
      Oracle Database 10g Enterprise Edition Version 10.2.0.2.0.

      Code for establishing the connection is as follows:
      //
      public static Connection createDBConnection() {
      try {
      Class.forName("oracle.jdbc.driver.OracleDriver");
      dbConnection = DriverManager.getConnection(url, uname, pwd);
      return dbConnection;
      } catch (Exception e) {
      e.printStackTrace();
      return null;
      }
      }

      //
      The connection is getting created successfully,but the problem is that, if we are trying to insert more rows or perform any other operation on the connection after 1 hour, after its creation, the connection is getting failed with exception:


      ********************************************************************************************************
      java.sql.SQLException: Io exception: Connection reset
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:287)
      at oracle.jdbc.driver.T4CCallableStatement.execute_for_rows(T4CCallableStatement.java:889)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1161)
      at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3001)
      at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3093)
      at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4286)
      at oracle.apps.ask.adr.model.database.DB.insertFileDetailsforProduct(DB.java:153)
      at oracle.apps.ask.adr.model.codeartifacts.ProcessAllFiles.run(ProcessAllFiles.java:360)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
      at java.util.concurrent.FutureTask.run(FutureTask.java:123)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
      at java.lang.Thread.run(Thread.java:595)
      Thread Thread0 caused exception while processing the directory /ade_autofs/ade_fusion_linux/FUSIONAPPS_PT.HCMM6C_LINUX.rdd/LATEST/fusionapps/hcm
      java.sql.SQLException: Closed Connection
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:240)
      at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:1233)
      at oracle.apps.ask.adr.model.database.DB.commit(DB.java:95)
      at oracle.apps.ask.adr.model.codeartifacts.ProcessAllFiles.run(ProcessAllFiles.java:362)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
      at java.util.concurrent.FutureTask.run(FutureTask.java:123)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
      at java.lang.Thread.run(Thread.java:595)
      java.sql.SQLException: Closed Connection
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:240)
      at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:1233)
      at oracle.apps.ask.adr.model.database.DB.commit(DB.java:95)
      at oracle.apps.ask.adr.model.ADRTemp.main(ADRTemp.java:302)
      Process exited with exit code 0.
      ****************************************************************************************************************


      Thanks in advance for your help.

        • 1. Re: java.sql.SQLException: Io exception: Connection reset
          Joe Weinstein-Oracle
          You should check the DBMS error log. The error you see is simply the driver
          discovering that the DBMS hase dropped the connection. This is usually
          because of a DBMS bug/limitation.
          • 2. Re: java.sql.SQLException: Io exception: Connection reset
            Andy Klock
            oracle.jdbc.driver.OracleDriver is a very old deprecated driver. You should switch to the more recent oracle.jdbc.OracleDriver. See "Starting With Oracle JDBC Drivers [ID 401934.1]" for a nice writeup on Oracle jdbc.

            However, it almost seems like the connection is behind a firewall and that is timing out. You either need to:

            1) Tell your network admins to stop doing that (though firewalls aren't the only thing that sever connections)
            2) Determine if you really truly need that connection open for over an hour, couldn't you just issue a connect and close it when you are done?
            3) If you need it open always, change your code to handle these breaks, so you can reconnect and reissue the statement when there is a break (note, the error is different with oracle.jdbc.OracleDriver), or...
            4) Move to a pool! Let the pool manage your connections. If it gets severed? Let it reopen another.

            But do upgrade your driver and have a chat with your network admin.
            • 3. Re: java.sql.SQLException: Io exception: Connection reset
              712753
              Please let us know how we can check DBMS error logs, thanks for your replies. :)
              • 4. Re: java.sql.SQLException: Io exception: Connection reset
                Andy Klock
                The log Joe is most likely referring to is the Oracle Listener log. This can can typically be found on the database server $ORACLE_HOME/network/logs/listener.log (though, this isn't always the case so you may need help from your dba. Another helpful log is the Oracle alert log, which in 10g can be found at the location specified here:

                select value from v$parameter where name = 'background_dump_dest';

                Though, if a break is consistently happening after a reproducible time interval, then I'm still leaning toward a firewall or a timeout setting in the Oracle listener.