• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to use DBCP with JNDI ?

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i am new to struts, I want to use JNDI with DBCP.Is it Possiable?
For DBCP i have use Struts-config
Q1) Where to configure for JNDI?
Q2) What are advantages and disadvantages of using DBCP?
Q3) Which is best approach either to write ConnectionPool classes
or use DBCP?( i have mentioned code below)







 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Q3) Which is best approach either to write ConnectionPool classes
or use DBCP?


Answer: Neither.

The Struts DBCP datasource configuration utility has been deprecated. It's no longer supported in Version 1.3.5 and above. I would strongly recommend that you not use it.

There's no need to "roll your own" connection pooling utility either. Any Application Server worth using has its own connection pooling configuration utility. They have put a lot of time and effort into making it work efficiently with that specific App server, so why not use it?

The best practice for JDBC DataSources in a J2EE application is to use your App server's configuration utility to set up a DataSource and store a reference to it in JNDI. In your application code you simply look up the reference in JNDI and use the retrieved DataSource to get a JDBC Connection.
 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I agree with Merrill. you should use app server based connection pooling. because it works efficiently than our code. for more details check out

http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html

milan.
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic