Announcement Announcement Module
Collapse
No announcement yet.
Please I need Help in "Closed Connection Problem" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Please I need Help in "Closed Connection Problem"

    Hi everybody I'm new in these forum & I need Help please i know that may have been discussed before So please refer me the answer which could help because I sent the same message to other forums..

    I'm using hibernate 2.0 with spring & oracle 9 database with tomcat 5.5 application server & here's a part of my application context file :
    ================================================== ====
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location">
    <value>classpath:labsupport.properties</value>
    </property>
    </bean>

    <bean id="labDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName">

    <value>@db.driver@</value>

    </property>
    <property name="url">
    <value>@db.url@</value>
    </property>
    <property name="username">
    <value>@db.user@</value>
    </property>
    <property name="password">
    <value>@db.password@</value>
    </property>
    </bean>


    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="mappingResources">
    <list>
    <value>com/onassignment/search/JobTypes.hbm.xml</value>

    </list>
    </property>
    ================================================== ====
    I got this problem "closed connection" & this happened when a normal hibernate query is excuted
    return hibernateTemplate.find("from JobType order by JobDescription");
    inside DAO object
    & here's a part of the stack trace
    ================================================== =====
    Hibernate: select jobtype0_.jobTypeKey as jobTypeKey, jobtype0_.division as division, jobtype0_.jobDescription as jobDescr3_ from jobTypes jobtype0_ order by JobDescription
    javax.faces.FacesException: Expression: '#{form.jobTypeChoices}'
    at org.apache.myfaces.context.servlet.ServletExternal ContextImpl.dispatch(ServletExternalContextImpl.ja va:410)
    ....

    Caused by: org.springframework.jdbc.UncategorizedSQLException : (Hibernate operation): encountered SQLException [Closed Connection]; nested exception is java.sql.SQLException: Closed Connection
    at org.springframework.jdbc.support.SQLStateSQLExcept ionTranslator.translate(SQLStateSQLExceptionTransl ator.java:94)
    at org.springframework.jdbc.support.SQLErrorCodeSQLEx ceptionTranslator.translate(SQLErrorCodeSQLExcepti onTranslator.java:281)
    at org.springframework.orm.hibernate.HibernateAccesso r.convertJdbcAccessException(HibernateAccessor.jav a:249)
    at org.springframework.orm.hibernate.HibernateAccesso r.convertHibernateAccessException(HibernateAccesso r.java:231)
    at org.springframework.orm.hibernate.HibernateTemplat e.execute(HibernateTemplate.java:248)
    at org.springframework.orm.hibernate.HibernateTemplat e.executeFind(HibernateTemplate.java:263)
    at org.springframework.orm.hibernate.HibernateTemplat e.find(HibernateTemplate.java:498)
    at com.onassignment.search.dao.JobTypeChoicesDAO.getA ll(JobTypeChoicesDAO.java:9)
    at com.onassignment.search.SearchForm.loadJobTypeChoi ces(SearchForm.java:131)
    at com.onassignment.search.SearchForm.getJobTypeChoic es(SearchForm.java:74)
    ... 55 more
    Caused by: java.sql.SQLException: Closed Connection
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:269)
    at oracle.jdbc.driver.OracleConnection.privatePrepare Statement(OracleConnection.java:962)
    at oracle.jdbc.driver.OracleConnection.prepareStateme nt(OracleConnection.java:869)
    at org.apache.commons.dbcp.DelegatingConnection.prepa reStatement(DelegatingConnection.java:187)
    at net.sf.hibernate.impl.BatcherImpl.getPreparedState ment(BatcherImpl.java:260)
    at net.sf.hibernate.impl.BatcherImpl.getPreparedState ment(BatcherImpl.java:235)
    at net.sf.hibernate.impl.BatcherImpl.prepareQueryStat ement(BatcherImpl.java:66)
    at net.sf.hibernate.loader.Loader.prepareQueryStateme nt(Loader.java:779)
    at net.sf.hibernate.loader.Loader.doQuery(Loader.java :265)

    ================================================== =====
    So please anybody can help me to solve this problem ..Thanks in advance

    Karim El-baghdady

  • #2
    It appears to be a problem with your oracle db/driver. See why the connection is closed (maybe timeout or the result is too big for it to handle). Try also other datasources like c3p0 (just to be sure).

    Comment


    • #3
      Thanks alot costin for your quick reply & I'll try another datasource ..

      Comment


      • #4
        I've Changed datasource to c3p0:
        ========================================
        <bean id="ntDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <property name="driverClass">

        <value>@db.driver@</value>

        </property>
        <property name="jdbcUrl">
        <value>@db.url@</value>
        </property>
        <property name="user">
        <value>@db.user@</value>
        </property>
        <property name="password">
        <value>@db.password@</value>
        </property>
        </bean>
        ========================================
        & I got the same stack trace except the error changed to :
        ---------------------------------------------------------
        Caused by: java.sql.SQLException: Io exception: Connection timed out
        instead of :
        Caused by: java.sql.SQLException: Closed Connection

        So, please Do you have idea about this problem or what should i do inorder to solve this problem ..Thanks a lot

        Comment


        • #5
          The problem is at the database level. As you can see it's a low level exception that causes the connections to be dropped/closed/timed out. Talk with your DBA, make sure you have the latests jdbc driver for your database version and see if your don't have problems with the transportation over the wire.
          Anyway, the problem seems to be outside the java world .

          Comment


          • #6
            Thanks alot costin ,.. I was suspecting that problem is inside the Java world but now after i changed the Connection pool & I got a database exception I believe that it's at the database level as you said ..& I'll contact The my DBA ..Thanks again costin for your helpful information.

            Comment


            • #7
              Getting same problem

              I am getting the problem sometime.
              I think the problem is same like above. The problem is coming in certain interval. If app server restarted then the problem get solved and hibernate query can retrieve the data. But again after sometime getting the same problem.
              Can someone tell me what exactly the problem is? and what should be its remedy?

              11:45:43,796 WARN JDBCExceptionReporter:57 - SQL Error: 17002, SQLState: null
              11:45:43,859 ERROR JDBCExceptionReporter:58 - Io exception: Connection reset by peer: socket write error
              11:45:44,265 WARN JDBCExceptionReporter:57 - SQL Error: 17002, SQLState: null
              11:45:44,281 ERROR JDBCExceptionReporter:58 - Io exception: Connection reset by peer: socket write error
              11:45:45,281 ERROR JDBCTransaction:90 - Rollback failed
              java.sql.SQLException: Closed Connection
              at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
              at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
              at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:269)
              at oracle.jdbc.driver.OracleConnection.rollback(Oracl eConnection.java:1422)
              at org.apache.commons.dbcp.DelegatingConnection.rollb ack(DelegatingConnection.java:236)
              at org.apache.commons.dbcp.DelegatingConnection.rollb ack(DelegatingConnection.java:236)
              at net.sf.hibernate.transaction.JDBCTransaction.rollb ack(JDBCTransaction.java:86)

              Please take this as urgent problem. Thanks .

              Comment


              • #8
                Possibly the connection has timed out. I suggest to instruct the connection pool to verify connections before handing them out. DBCP does provide this feature, have a look at the documentation (see parameter "testOnBorrow").

                Regards,
                Andreas

                Comment


                • #9
                  now i am getting error Socket closed in stead of Closed Connection. Looking forward for a permanent resolution ..
                  Can anyone helps?

                  Comment

                  Working...
                  X