File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes connection pooling tomcat 5.0.28 urgent plz... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "connection pooling tomcat 5.0.28 urgent plz..." Watch "connection pooling tomcat 5.0.28 urgent plz..." New topic

connection pooling tomcat 5.0.28 urgent plz...

subbarao dachepalli

Joined: Jul 28, 2005
Posts: 5
Hi all,

I am trying connection pooling with tomcat 5.0.28.I have searched all sites.
I have put the follwing in server.xml file:

<Context path="/DBTest" docBase="DBTest"
debug="5" reloadable="true" crossContext="true">

<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest_log." suffix=".txt"

<Resource name="jdbc/TestDB"

<ResourceParams name="jdbc/TestDB">

I have put the following code in web.xml file

<description>DB Connection</description>

and i have written following code in one
Context context = new InitialContext();
DataSource ds = (DataSource)context.lookup("java:comp/env/jdbc/DBTest");

and then i got the error:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

so i have changed code like
Context context = getInitialContext();

static public Context getInitialContext() throws Exception {
Hashtable h = new Hashtable();
h.put(Context.PROVIDER_URL, "jdbc:mysql://");
h.put(Context.SECURITY_PRINCIPAL, "ccm");//user
h.put(Context.SECURITY_CREDENTIALS, "ccmccm"); //password
return new InitialContext(h);
javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.commons.dbcp.BasicDataSourceFactory [Root exception is java.lang.ClassCastException]

i have put commonsdbcp.jar,commonspool.jar,coomonscollections.jar files on classpath.

But i still not able to get it right?
can any body help me?

Advance Thanks

I agree. Here's the link:
subject: connection pooling tomcat 5.0.28 urgent plz...
It's not a secret anymore!