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

    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
    at org.hibernate.exception.SQLStateConverter.convert( SQLStateConverter.j
    at org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelp
    at org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelp
    at org.hibernate.jdbc.ConnectionManager.openConnectio n(ConnectionManager
    at org.hibernate.jdbc.ConnectionManager.getConnection (ConnectionManager.
    at org.hibernate.jdbc.AbstractBatcher.prepareQuerySta tement(AbstractBatc
    at org.hibernate.loader.Loader.prepareQueryStatement(
    at org.hibernate.loader.Loader.doQuery( 1)
    at org.hibernate.loader.Loader.doQueryAndInitializeNo nLazyCollections(Lo
    at org.hibernate.loader.Loader.doList( 7)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(L
    at org.hibernate.loader.Loader.list(
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoa
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(Que ryTranslatorImpl.ja
    at org.hibernate.engine.query.HQLQueryPlan.performLis t(
    at org.hibernate.impl.SessionImpl.list(SessionImpl.ja va:1014)
    at org.hibernate.impl.QueryImpl.list( 9)
    at com.desige.webDocuments.persistent.utils.Hibernate Util.createQuery(Hi
    at com.focus.wonderware.actions.HandlerProcesosWonder Ware.HiloChecSacopI
    ntouchWonderwareHijo(HandlerProcesosWonderWare.jav a:383)
    at com.focus.wonderware.actions.HandlerProcesosWonder Ware.getTagnameWond
    at com.focus.wonderware.intocuh_sacop.actions.HiloChe cheaSacop_Intouch.r
    at com.focus.wonderware.intocuh_sacop.actions.HiloChe cheaSacop_Intouch.r
    Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection,
    pool exhausted
    at org.apache.commons.dbcp.PoolingDataSource.getConne ction(PoolingDataSo
    at org.apache.commons.dbcp.BasicDataSource.getConnect ion(BasicDataSource
    at org.hibernate.connection.DatasourceConnectionProvi der.getConnection(D
    at org.hibernate.jdbc.ConnectionManager.openConnectio n(ConnectionManager
    ... 18 more
    Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
    at org.apache.commons.pool.impl.GenericObjectPool.bor rowObject(GenericOb
    at org.apache.commons.dbcp.PoolingDataSource.getConne ction(PoolingDataSo

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


    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
    Rep Power


    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, 11:25 AM
  2. Threads
    By one198 in forum Threads and Synchronization
    Replies: 1
    Last Post: 11-20-2007, 07:15 PM
  3. Using threads as a countdowntimer
    By lacoste in forum Threads and Synchronization
    Replies: 4
    Last Post: 07-20-2007, 02:06 PM
  4. Replies: 2
    Last Post: 06-30-2007, 04:01 PM
  5. Server n threads
    By ferosh in forum Networking
    Replies: 2
    Last Post: 04-28-2007, 11: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