• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC error with Tomcat startup (upgraded to jdk 5)

 
Robert Bonslater
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

installed jdk 1.5 from jdk 1.4 on Tomcat server environment. My JDBC connection with my driver was working fine until I installed the new java version. What has changed since 1.4?

Here's the error message:
java.sql.SQLException: Cannot load JDBC driver class 'org.gjt.mm.mysql.Driver'
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:529)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:312)
at com.wrox.tourism.db.util.DBInitServlet.init(DBInitServlet.java:34)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1044)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:88
7)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:3820)
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Appears to be a classpath problem at the first look, the jar file containing MySQL JDBC driver cannot be found by Tomcat (if you are setting up the connection pool in Tomcat) or by your application.

Have you checked if it is present in the locations that Tomcat includes jar files from?
 
Robert Bonslater
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the name of this jar file that must be recognized by the classpath?
 
Annie Smith
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Robert Bonslater:
What is the name of this jar file that must be recognized by the classpath?


It should be mysqldb.jar or something similar.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mysql jdbc drivers

My sql connector/j
 
Robert Bonslater
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys, I finally got it.

Just needed to place that "mysql-connector-java-3.0.16-ga.jar" file into my JAVA_HOME\jre\lib\ext directory. The downfall of this though is that I might forget again when upgrading java versions again. The best thing for me to do is set it in my classpath environment.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert,

Are you setting up a connection pool through Tomcat?

If so, I think you are supposed to have the jar file in the Tomcat common/lib directory. There are some subtle issues with class loading when using an application server, see if you can find some more information on setting up classpath for Tomcat.

HTH.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic