-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Too many connections
PostPosted: Sun Feb 21, 2010 6:03 pm 
Newbie

Joined: Wed Feb 21, 2007 4:45 am
Posts: 3
Hello,
I try to close all connections and resources so as to avoid "lost" active database connections.
The code structure is:
Code:
      javax.persistence.EntityManager entityManager = null;
      javax.persistence.EntityTransaction transaction = null;
      try {
         entityManager = com.primari.business.PrimariUtility
               .getEntityManager();
         transaction = entityManager.getTransaction();
         transaction.begin();
         // Here I do all the CRUD stuff
         transaction.commit();
      } catch (RuntimeException e) {
         if (transaction != null && transaction.isActive())
            transaction.rollback();
         throw e;
      } finally {
         entityManager.close();
      }


"com.primari.business.PrimariUtility.getEntityManager()" has the following code:
Code:
   public static EntityManager getEntityManager() {
      EntityManagerFactory emFactory = Persistence
            .createEntityManagerFactory("primall");
      EntityManager entityManager = emFactory.createEntityManager();
      return entityManager;
   }


I really don't understand why after testing the application a few minutes Hibrernate thows a "Too man connections" exception.


Top
 Profile  
 
 Post subject: Re: Too many connections
PostPosted: Mon Feb 22, 2010 12:49 am 
Newbie

Joined: Sun Feb 14, 2010 8:08 am
Posts: 12
If the error is coming from hibernate you need to set connection pool size and pool properties in your hibernate configuration. And if the error message is from Datasource you need to set the size depending on which Datasource your using.


Top
 Profile  
 
 Post subject: Re: Too many connections
PostPosted: Mon Feb 22, 2010 3:09 am 
Newbie

Joined: Wed Feb 21, 2007 4:45 am
Posts: 3
Hello,
I changed the max. connections in the hibernate configuration file and now the error no longer appears. I didn't think about it :S
Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.