• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC connection pooling

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
A knibbs
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry for mutiple posts.

URL I found which is very useful for JDBC optomization.
 
Fire me boy! Cool, soothing, shameless self promotion:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic