• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

db connection pooling to mssql from Tomcat 4.0.6

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I know this was a very debated problem and often resolved. Db connection pooling to MSSQL Server from Tomcat 4.0.6. The error is:

org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null', cause: No suitable driver

I have put the commons-collections-3.0.jar, commons-dbcp-1.1.jar, commons-pool-1.1.jar, jtds-0.8-rc1.jar files in %TOMCAT_HOME%\common\lib\
My configuration files looks like:


1. %TOMCAT_HOME%\conf\server.xml

<context path="/testWEB" docBase="testWEB.war" debug="1" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="testWEB_log."
suffix=".txt" timestamp="true"/>
<Resource name="jdbc/mspool" auth="Container" type="javax.sql.DataSource" />
<ResourceParams name="jdbc/mspool">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>user</name>
<value>razvan</value>
</parameter>
<parameter>
<name>password</name>
<value>razvan</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>net.sourceforge.jtds.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:jtds:sqlserver://localhost:1433/test;User=razvan;Password=razvan</value>
</parameter>
</ResourceParams>
</context>


2. %TOMCAT_HOME%\webapps\testWEB.war\WEB-INF\web.xml:

<web-app>
<display-name>testWEB</display-name>
<description>MSSQL Test App</description>
<resource-ref>
<res-ref-name>jdbc/mspool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>

3. and Conn.java:

Context initCtx = new InitialContext();
DataSource ds = (DataSource)initCtx.lookup("java:comp/env/jdbc/mspool");
if (ds != null)
{
dbConnection = ds.getConnection();
}



If you have a solution, please give some feedback.


Thank you

Razvan Droscaru
 
I've been selected to go to the moon! All thanks to this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic