File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes  How to use DBCP with JNDI ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark " How to use DBCP with JNDI ?" Watch " How to use DBCP with JNDI ?" New topic

How to use DBCP with JNDI ?

Satyajeet Kadam
Ranch Hand

Joined: Oct 19, 2006
Posts: 224
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)

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.

Consultant, Sima Solutions
Milan Jagatiya
Ranch Hand

Joined: Jan 01, 2007
Posts: 164
I agree with Merrill. you should use app server based connection pooling. because it works efficiently than our code. for more details check out


Milan.<br />I can because I think I can...
I agree. Here's the link:
subject: How to use DBCP with JNDI ?
It's not a secret anymore!