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

db connection pooling to mssql from Tomcat 4.0.6

 
Razvan Droscaru
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic