• Post Reply Bookmark Topic Watch Topic
  • New Topic

connection pooling tomcat 5.0.28 urgent plz...  RSS feed

subbarao dachepalli
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 pool.java:
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

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!