-->
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.  [ 1 post ] 
Author Message
 Post subject: pool keeps growing
PostPosted: Thu Dec 02, 2004 9:59 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 5:03 am
Posts: 34
Hibernate version: 2.1 final

I have a webapplication that uses two different databases.

I created two different session factories, like this:

public class ServiceLocatorTotal {

// variables
public static final ThreadLocal session = new ThreadLocal();

// methods
/**
* @return session
* @throws Exception
*/
public static Session currentSession() throws Exception {

Session s = (Session) session.get();
if (s == null) {
SessionFactory sf = new Configuration().configure("/dbTotal.cfg.xml").buildSessionFactory();
s = sf.openSession();
session.set(s);
}
return s;
}

/**
* @throws Exception
*/
public static void closeSession() throws Exception {
Session s = (Session) session.get();
session.set(null);
if (s != null) {
s.close();
}
}
}

Both use another configuration file. At first i seems to work fine. But every time i query the database, a new connection is created. This continues until no more connections can't be created.

It works fine when i use one database and one session factory. But with two, it fails. I hope someone can point me in the right direction.


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

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.