Sounds like you're on the right path. It's usually good practice to have a connection per thread. A H2 connection is thread safe, but I don't think that is the case for all DBs. But anyway, a connection per thread is better, because then if you turn on multithreaded mode for H2 you will get better concurrency. If all your threads share a single connection then they will synchronise on the connection, so only 1 thread will be able to use it at a time.

Just make sure your threads return the connection to the pool when they have finished with it.

Depending on your particular case, you might not get any performance improvement, sometimes a single thread is better. You really need to test and see what works better for your particular case.

HTH Ryan


On 14/08/2013 9:34 AM, Shiva wrote:
I am having multiple threads processing the data and querying against H2 database each thread might query h2 2,000,000 times. I am thinking if each thread has it own H2 connection will it improve the performance Vs having single connection for all threads?
I am thinking of using the connection pool in the following way.
JdbcConnectionPool.create(memoryConnectionString, userName, password);

Any help is appreciated.
Thanks
Shiva
--
You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to