Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cant connect to SQL server with jtds 1.2.2

 
Lee Fei Tye
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have this problem where, during development in Eclipse, The database connection has no issues, however when i deploy the updates to the main server, it fails.

Im using tomcat 6.0

I've dump the jtds and mysql drivers to commons lib folder.

I've created the lookup context as below to tomcat config directory


set



When i query the mysql database, it works however when i attempt to query the SQL server database, it catches the exception and return an error which in development environment didn't.

Where did i go wrong? what could possibly be the problem?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and what is the error it returns?
 
Lee Fei Tye
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'net.sourceforge.jtds.jdbc.Driver'
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the driver files appear to not be on your classpath.

Are you sure the correct jtds jar file is in the main Tomcat instance's common/lib directory?
 
Lee Fei Tye
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
positive.

its in tomcat/common/library and also public_html/emailregistration/WEB-INF/lib

I've tried putting it else where as well but was not successful.
 
Lee Fei Tye
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im facing the same problem as discuss in this top: http://forums.sun.com/thread.jspa?threadID=635640

where can i download the commons-jdbc.jar?

cant seem to find it anywhere.
 
Lee Fei Tye
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Problem Solved.

What i did was to add

commons-dbcp-1.2.2.jar
commons-pool-1.4.jar
commons-collections-3.2.1.jar - already added initially

to the class path of the application and tomcat

and add factory="org.apache.commons.dbcp.BasicDataSourceFactory" as can be seen below


to the context.

I got the solution thanks to the 2 topics below

http://www.coderanch.com/t/87782/Tomcat/One-resources-defined-context-xml#470239
http://forums.sun.com/thread.jspa?threadID=635640

~Nick
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic