5 Replies Latest reply on May 23, 2013 12:06 PM by 939520

    Regarding connection closed Exception



      We are getting connection closed error some time after starting tomcat server...

      *WARN [http-8080-5] (JDBCExceptionReporter.java:100) - SQL Error: 17008, SQLState: 08003*
      *ERROR [http-8080-5] (JDBCExceptionReporter.java:101) - Closed Connection*
      *ERROR [http-8080-5] (LoginAction.java:358) - org.hibernate.exception.JDBCConnectionException: could not execute query*

      and some time we are hetting below also

      *WARN [http-8080-9] (JDBCExceptionReporter.java:100) - SQL Error: 17002, SQLState: null*
      *ERROR [http-8080-9] (JDBCExceptionReporter.java:101) - Io exception: Connection reset by peer: socket write error*
      *ERROR [http-8080-9] (LoginAction.java:388) - org.hibernate.exception.GenericJDBCException: could not execute query*

      we are using java 1.5 , hibernate 3.3 , struts & Db : oracle
      for jdbc, we are using ojdbc5.jar.

      Can pls let me know what could be the issues?

      Edited by: 994990 on 22-May-2013 05:16

        • 1. Re: Regarding connection closed Exception
          Joe Weinstein-Oracle
          The first thing to do is to check the DBMS error log. So far, your symptoms indicate that
          the driver internally found that the DBMS (or possibly the network) killed the socket
          that was used for the connection to the DBMS.
          • 2. Re: Regarding connection closed Exception
            I would wonder how connections are managed. Is a connection pool used? If not that may help since connection pools tend to be equipped to deal with stale connections closed by the server.
            • 3. Re: Regarding connection closed Exception

              yes we are using connection pooling.
              This is our configuratinon details...
              <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
                   <property name="hibernate.connection.pool_size">100</property>
                   <property name="show_sql">true</property>
                   <property name="hibernate.jdbc.batch_size">50</property>
                   <property name="hibernate.cache.use_second_level_cache">false</property>
                   <property name="current_session_context_class">thread</property>
              And we are maintaining connections by using HibernateSessionFactory...

              Here our code snippet

              configFileURL = HibernateSessionFactory.class.getResource(CONFIG_FILE_LOCATION);
              sessionFactory = configuration.buildSessionFactory();

              public static Session getSession() throws HibernateException {
              Session session = (Session) threadSession.get();

                        if (session == null || !session.isOpen()) {
                             if (sessionFactory == null) {
                             session = (sessionFactory != null) ? sessionFactory.openSession()
                                       : null;
                        return session;
              • 4. Re: Regarding connection closed Exception
                Well listen to Joe, check the DBMS logs, and also read the manual of the connection pool implementation to be sure you setup the pool parameters correctly. Because its Oracle that is closing the connections, so you need to find out WHY it is doing that.
                • 5. Re: Regarding connection closed Exception
                  Perhaps your problem may be related to holding onto the session too long and/or not using them on a thread safe way (can't be sure since I didn't look at the rest of your code).