JDBC Connection Pool

Apache Common DBCP

Maven Dependency

<dependency>
 <groupId>commons-dbcp</groupId>
 <artifactId>commons-dbcp</artifactId>
 <version>1.4</version>
</dependency>

Spring Config

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
 <property name="driverClassName" value="${jdbc.driver.name}" />
 <property name="url" value="${jdbc.url}" />
 <property name="username" value="${jdbc.user}" />
 <property name="password" value="${jdbc.pwd}" />
......
 </bean>

Tomcat JDBC Pool

Maven Dependency

<dependency>
 <groupId>org.apache.tomcat</groupId>
 <artifactId>tomcat-jdbc</artifactId>
 <version>7.0.70</version>
 <scope>provided</scope> ←If deploy on Tomcat
</dependency>

String config

<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close">
 <property name="driverClassName" value="${jdbc.driver.name}" />
 <property name="url" value="${jdbc.url}" />
 <property name="username" value="${jdbc.user}" />
 <property name="password" value="${jdbc.pwd}" />
......
 </bean>

Reference

http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html

http://blog.zenika.com/2013/01/30/using-tomcat-jdbc-connection-pool-in-a-standalone-environment/

https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/Bean.html#destroyMethod–

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s