user801138
user801138

Reputation: 295

Hibernate connection management in sessionfactory

I have a question related to hibernate connention managing/pooling.

If I write sessionFactory.openSession(), will hibernate create a fresh, new JDBC connection?

My C3PO properties look like this:

    <property name="hibernate.c3p0.acquire_increment">1</property>
    <property name="hibernate.c3p0.min_size">0</property>
    <property name="hibernate.c3p0.max_size">10</property>

Upvotes: 0

Views: 1902

Answers (2)

HamoriZ
HamoriZ

Reputation: 2438

It will check the pool and if there is any open non-locked connection, then it will use that one. If all the connections in the pool are currently used or there is no connection, then it will open 1. If the connection pool contains 10 locked connection then it will give an exception

Upvotes: 1

Thilo
Thilo

Reputation: 262464

If you got c3p0 configured properly, you will get a pooled connection (not a fresh one).

Upvotes: 2

Related Questions