views:

402

answers:

2

Which datasource best supports multi-threading in Spring?

A: 

JDBC Connections are not thread-safe. You have to manage that yourself.

If you're using Spring in a web app, it's usually one thread per request. If you pool your connections, that will mean the thread gets its connection from the pool, uses it, and returns it to the pool. If you don't share it you're unlikely to have issues.

duffymo
+6  A: 

To support multi-threading you would need to use a data source that supports connection pooling so that each thread can use its own connection.

The most common database connection pools are Commons DBCP and C3p0 and can be easily integrated with Spring.

Mark
yes Mark ..using C3P0 resolved my issues greatly :)!DBCP is fairly outdated!
hakish