7

Can someone tell me or point me to a document/tutorial that explains how to use connection pooling in Spring?

Danubian Sailor
  • 1
  • 38
  • 145
  • 223
Shyam Kumar Sundarakumar
  • 5,649
  • 13
  • 42
  • 69

3 Answers3

9

You might use a pooled datasource from the jdbc driver. E.g. in oracles library there is one:

<bean id="dataSource"
    class="oracle.jdbc.pool.OracleConnectionPoolDataSource">
    <property name="URL" value="jdbc:oracle:thin:@wherever:1234:whatever" />
    <property name="user" value="theuser" />
    <property name="password" value="thepassword" />
</bean>
Dr. Hans-Peter Störr
  • 25,298
  • 30
  • 102
  • 139
9

Spring doesn't support inbuilt pooling. You should use a third party pool as mentioned above. DBCP and c3p0 both work like a charm with spring. All you need to do is when defining a datasource in your context.xml, just use DBCP to define it.

Danubian Sailor
  • 1
  • 38
  • 145
  • 223
Gaurav
  • 1,466
  • 3
  • 17
  • 24
1

AFAIK Spring doesn't include a pooled DataSource... you can use Apache DBCP for that, if you need a connection pool in a J2SE application. For container-hosted apps, you should configure a DataSource in the container and use it from your app.

Chochos
  • 5,155
  • 22
  • 27