c3p0's max number of connections doesn't work in Linux
I have a java application that uses hibernate for O/R mapping and I also use c3p0 connection pooling that ships together with hibernate. The DB is Oracle.
This is in my hibernate.cfg.xml
:
<property name="hibernate.c3p0.min_size">3</property>
<property name="hibernate.c3p0.max_size">5</property>
<property name="hibernate.c3p0.max_statements">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.idleTestPeriod">120</property>
This is how I obtain the hibernate session:
public class HibernateUtil {
private static Logger log = Logger.getLogger(HibernateUtil.class);
private static final SessionFactory sessionFactory;
private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure(CONFIG_FILE_LOCATION).buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
log.fatal("Initial SessionFactory开发者_StackOverflow中文版 creation failed." + ex.getMessage());
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
But when I run SELECT * FROM V$SESSION WHERE machine='xxx';
in Oracle the number of connections can reach 20, which is greater than max_size
.
The max connections don't work in Linux environment but they do in Unix and Windows. Any setting in Linux that needs to be tweaked?
I'm also suspecting there is a cache of the application somewhere, as previously I set max_size
of 20. I'm running the application in Tomcat 5.5. But I don't know of such an application cache in Tomcat.
Another info: I'm running Linux 2.6.9-34.ELsmp. Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
Thanks.
I'd guess you have additional DB sessions opened not from your application. For example, there should be an additional connection - the one you're using to run the SELECT
statement.
精彩评论