| Author |
JDBC connection pooling
|
A knibbs
Ranch Hand
Joined: Aug 23, 2006
Posts: 158
|
|
Hi all I am wondering if someone might happen to have a link to a sample application using best practices for a JDBC connection pool in struts. thanks in advance for your time.
|
 |
Prabhu Venkatachalam
Ranch Hand
Joined: Nov 16, 2005
Posts: 502
|
|
Struts itself has connection pooling support using DBCP(Database Connection Pooling). commons-pool-1.2.jar which comes with Sturts download. For configuring DBCP with sturts, URL Example: <data-sources> <data-source type="org.apache.commons.dbcp.BasicDataSource" key="mysql"> <set-property property="driverClassName" value="com.mysql.jdbc.Driver"></set-property> <set-property property="url" value="jdbc:mysql://testServer/test"></set-property> <set-property property="username" value="test"></set-property> <set-property property="password" value="test"></set-property> <set-property property= "maxCount" value= "100"></set-property> <set-property property= "minCount" value= "0"></set-property> </data-source> </data-sources>
|
Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
|
 |
A knibbs
Ranch Hand
Joined: Aug 23, 2006
Posts: 158
|
|
I have the data source defined and am able to make connections. I guess what I am asking moreso is what is the best manner to cget the connection as well as relinquish them. The thought right now is to pass a connection as a parameter and close it using connection.close. Would that be sufficient ? thanks again in advance.
|
 |
Prabhu Venkatachalam
Ranch Hand
Joined: Nov 16, 2005
Posts: 502
|
|
1. use DataSource to get connection. 2. close connection when ever you done with it. This is optimized way of using JDBC Connection. hth,
|
 |
Prabhu Venkatachalam
Ranch Hand
Joined: Nov 16, 2005
Posts: 502
|
|
sorry for mutiple posts. URL I found which is very useful for JDBC optomization.
|
 |
 |
|
|
subject: JDBC connection pooling
|
|
|