H2 is thread safe. You should use you a connection per thread and yes
you can share the JdbcConnectionPool between threads. No need to
serialize access, the database does that internally. It defaults to
synchronising on the database, so only 1 statement can run at a time. If
you want concurrent access by multiple threads then you can use the
MULTI_THREADED=1 parameter in the connection string which then
synchronises on the session instead of the database.
Ryan
On 25/12/2011 11:57 AM, Bruce Alspaugh wrote:
multiple
threads running in the same JVM access the same database so long as each
thread uses its own Connection?
Can multiple threads share the same JdbcConnectionPool instance to
concurrently obtain and release connections to the same database?
Is it recommended to use locking to serialize access to the database
within the same JVM?
Bruce
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.