Results 1 to 3 of 3
  1. #1
    Marty is offline Member
    Join Date
    May 2007
    Posts
    38
    Rep Power
    0

    Default threads and hibernate

    I run a thread that makes connections with hibernate, they are querys of hibernate and if the table has been updated I insert records
    It works ok but when I execute the thread, after 2 minutes lost the database connection...
    do you know what is the problem?
    how can I fix?

    org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledN onSpecificException
    (SQLStateConverter.java:91)
    at org.hibernate.exception.SQLStateConverter.convert( SQLStateConverter.j
    ava:79)
    at org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelp
    er.java:43)
    at org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelp
    er.java:29)
    at org.hibernate.jdbc.ConnectionManager.openConnectio n(ConnectionManager
    .java:307)
    at org.hibernate.jdbc.ConnectionManager.getConnection (ConnectionManager.
    java:109)
    at org.hibernate.jdbc.AbstractBatcher.prepareQuerySta tement(AbstractBatc
    her.java:105)
    at org.hibernate.loader.Loader.prepareQueryStatement( Loader.java:1561)
    at org.hibernate.loader.Loader.doQuery(Loader.java:66 1)
    at org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections(Lo
    ader.java:223)
    at org.hibernate.loader.Loader.doList(Loader.java:214 7)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(L oader.java:2026)
    at org.hibernate.loader.Loader.list(Loader.java:2021)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoa der.java:369)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(Que ryTranslatorImpl.ja
    va:298)
    at org.hibernate.engine.query.HQLQueryPlan.performLis t(HQLQueryPlan.java
    :137)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.ja va:1014)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:7 9)
    at com.desige.webDocuments.persistent.utils.Hibernate Util.createQuery(Hi
    bernateUtil.java:176)
    at com.focus.wonderware.actions.HandlerProcesosWonder Ware.HiloChecSacopI
    ntouchWonderwareHijo(HandlerProcesosWonderWare.jav a:383)
    at com.focus.wonderware.actions.HandlerProcesosWonder Ware.getTagnameWond
    erwareQueStanPreconfiguradosInSacopIntouch(Handler ProcesosWonderWare.java:603)
    at com.focus.wonderware.intocuh_sacop.actions.HiloChe cheaSacop_Intouch.r
    unTask(HiloChecheaSacop_Intouch.java:103)
    at com.focus.wonderware.intocuh_sacop.actions.HiloChe cheaSacop_Intouch.r
    un(HiloChecheaSacop_Intouch.java:64)
    Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection,
    pool exhausted
    at org.apache.commons.dbcp.PoolingDataSource.getConne ction(PoolingDataSo
    urce.java:103)
    at org.apache.commons.dbcp.BasicDataSource.getConnect ion(BasicDataSource
    .java:540)
    at org.hibernate.connection.DatasourceConnectionProvi der.getConnection(D
    atasourceConnectionProvider.java:69)
    at org.hibernate.jdbc.ConnectionManager.openConnectio n(ConnectionManager
    .java:304)
    ... 18 more
    Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
    at org.apache.commons.pool.impl.GenericObjectPool.bor rowObject(GenericOb
    jectPool.java:756)
    at org.apache.commons.dbcp.PoolingDataSource.getConne ction(PoolingDataSo
    urce.java:95)

  2. #2
    goldhouse is offline Senior Member
    Join Date
    Mar 2007
    Posts
    134
    Rep Power
    0

    Default

    How are you obtaining the connection ?
    JNDI bind or static variable ?
    Can you show me your HibernateUtil class and the way you call this ?
    The error shows you tried to execute the createQuery method without having connection .

  3. #3
    Nick15 is offline Member
    Join Date
    May 2007
    Posts
    38
    Rep Power
    0

    Default

    You are not liberating connections, your connection pool empties and exploits the world =)

Similar Threads

  1. Using threads
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-11-2007, 10:25 AM
  2. Threads
    By one198 in forum Threads and Synchronization
    Replies: 1
    Last Post: 11-20-2007, 06:15 PM
  3. Using threads as a countdowntimer
    By lacoste in forum Threads and Synchronization
    Replies: 4
    Last Post: 07-20-2007, 01:06 PM
  4. Replies: 2
    Last Post: 06-30-2007, 03:01 PM
  5. Server n threads
    By ferosh in forum Networking
    Replies: 2
    Last Post: 04-28-2007, 10:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •