I use hibernate and c3p0 for the database, and I have a Java application with ThreadPoolExecutor. What I do, I present various hibernate-related tasks for storing data using Hibernate using transactions and getCurrentSession. So i
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
<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 the stream from the artist, get the connection using getCurrentSession and execute session.saveOrUpdate (item). Now I have a couple of questions. What level of isolation should I use because I have 95% write / update and 5% read and read not interrupted by writing. I hit 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] (eg 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] (eg 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] (eg com.mchange.v2.c3p0.impl.NewPooledConnection@697506e6 )
Does this mean that I have only 1 connection in c3p0 or several connections in the same pool?
AM I USE THAT IT SHOULD BE USED
What isolation level is best suited for simultaneous recording?
thank everyone in advance if someone needs more data and explanations, just poke.
- EDIT: answers
As suggested from answerd, I checked the mysql server administrator, and there are more connections that are used to query .. so this is the CORRECT WAY to use it: D ... As for isolation levels, I try to allow