Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use DBCP with JNDI ?

 
Satyajeet Kadam
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • 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)







 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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.
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic