I am using hibernate and c3p0 for the database, and i have an java application, with ThreadPoolExecutor. What i am doing is, I am enquing different Tasks each related to hibernate, to store data with Hibernate using Transactions, and getCurrentSession. So I have
new ThreadPoolExecutor(CORE_POOL_SIZE, MAX_POOL_SIZE, KEEP_ALIVE_TIME, TimeUnit.MINUTES,taskQueue);
Runnable
{
@Override
public void run() {
Session session = HibernateDAO.getInstance().getCurrentSession();
Transaction tx = null;
try
{tx = session.beginTransaction(); .....
}
And hibernate.cfg thread org.hibernate.connection.C3P0ConnectionProvider 1
<!-- Database c3p0 settings -->
<property name="hibernate.c3p0.min_size">3</property>
<property name="hibernate.c3p0.max_size">3</property>
<property name="hibernate.c3p0.initialPoolSize">3</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
My goal is to get per thread from the executor, to get a connection using getCurrentSession, and execute session.saveOrUpdate(item), Now I have couple of questions. Which Isolation level should i use, because i have 95% writes/updates and 5% reads, and reads are not interupted by the writes. I get in the HTML log from log4j
905 pool-1-thread-1 DEBUG com.mchange.v2.resourcepool.BasicResourcePool trace com.mchange.v2.resourcepool.BasicResourcePool@434cb775 [managed: 3, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@697506e6)
905 pool-1-thread-5 DEBUG com.mchange.v2.resourcepool.BasicResourcePool trace com.mchange.v2.resourcepool.BasicResourcePool@434cb775 [managed: 3, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@697506e6)
965 pool-1-thread-4 DEBUG com.mchange.v2.resourcepool.BasicResourcePool trace com.mchange.v2.resourcepool.BasicResourcePool@434cb775 [managed: 3, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@697506e6)
Does this mean That i have only 1 Connection in c3p0, or multiple connections in one pool?
AM I USING IT AS IT SHOULD BE USED????
what level of isolation will be best for concurrent writes?
thanks in advance to all, if anyone needs more data and explanation just poke.
--EDIT: answered
As suggested from the answerd, I have checked the mysql server admin, and there are more connections which are used for quering.. so IT IS THE RIGHT WAY to use it :D... As for the isolation levels ill try to let