aspose file tools*
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 Spring in Action this week in the Spring 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
Author

connection pooling tomcat 5.0.28 urgent plz...

subbarao dachepalli
Greenhorn

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"
timestamp="true"/>

<Resource name="jdbc/TestDB"
auth="Container"
type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/TestDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<parameter>
<name>username</name>
<value>ccm</value>
</parameter>
<parameter>
<name>password</name>
<value>ccmccm</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://192.168.0.36:3306/ccm?autoReconnect=true</value>
</parameter>
</ResourceParams>
</Context>

I have put the following code in web.xml file

<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

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.INITIAL_CONTEXT_FACTORY,
"org.apache.commons.dbcp.BasicDataSourceFactory");
h.put(Context.PROVIDER_URL, "jdbc:mysql://192.168.0.82/ccm");
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

Regards
Subbarao.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: connection pooling tomcat 5.0.28 urgent plz...