Fedora Linux Support Community & Resources Center
  #1  
Old 25th February 2006, 05:51 AM
jlande37 Offline
Registered User
 
Join Date: Aug 2005
Posts: 3
Tomcat MySQL driver problem

I am having trouble conneting to MySQL from a jsp, I can however connect from a test class.
My test page is:
Quote:
<%@ page contentType="text/html; charset =iso-8859-1" language="java" import="java.sql.*" errorPage=""%>
<html>
<head>
<title>Display users from MySQL database</title>
</head>
<body>

<%
// define variables
String User;
String Password;

// define database parameters
String host="localhost"; // put in proper user name
String user="root"; // put in proper password
String pass="";
String db="mysql";
String tbl="user";
String conn;
%>

<table width='85%' border='0'cellpadding='4' cellspacing ='0'>
< tr >
<td width='200'>
<b><font size='1' face='Arial, Helvetica, sans-serif'>User</font></b>
</td>
<td width='200'>
<b><font size='1' face='Arial, Helvetica, sans-serif'>Password</font></b>
</td>
</ tr >

<%
Class.forName("com.mysql.jdbc.Driver ");

// create connection string
conn="jdbc:mysql://" + host + "/" + db + "?user=" + user +"&password=" +
pass;

// pass database parameters to JDBC driver
Connection Conn = DriverManager.getConnection(conn );

// query statement
Statement SQLStatement = Conn.createStatement ();

// generate query
String Query = "SELECT User,Password FROM user ORDER BY User asc ";

// get result
ResultSet SQLResult = SQLStatement.executeQuery(Query );

while(SQLResult.next ())
{
User = SQLResult.getString("User ");
Password = SQLResult.getString("Password ");

out.println ("< tr ><td><b><font size='1' face='Arial, Helvetica, sans-serif'>" + User + "</font></b></td><td><b><font size='1' face='Arial, Helvetica, sans-serif'>" + Password + "</font></b></td></ tr >");
}

// close connection
SQLResult.close ();
SQLStatement.close ();
Conn.close ();
%>

</table>
</body>
When I try to load the page I get:
Quote:
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: com.mysql.jdbc.Driver
org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

root cause

javax.servlet.ServletException: com.mysql.jdbc.Driver
org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:791)
org.apache.jsp.showUsers_jsp._jspService(org.apach e.jsp.showUsers_jsp:118)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

root cause

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1352)
org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1198)
org.apache.jasper.servlet.JasperLoader.loadClass(J asperLoader.java:127)
org.apache.jasper.servlet.JasperLoader.loadClass(J asperLoader.java:65)
java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:164)
org.apache.jsp.showUsers_jsp._jspService(org.apach e.jsp.showUsers_jsp:78)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.
Apache Tomcat/5.5.15
My Classpath is:
Quote:
:/opt/jdk1.5.0_06/jre/lib/ext/mysql-connector-java-3.1.12/mysql-connector-java-3.1.12-bin.jar:/opt/jdk1.5.0_06/jre/lib/ext/mysql-connector-java-3.1.12/mysql-connector-java-3.1.12-bin.jar
which I am setting in /etc/profile.d/java.sh, as well as in the tomcat startup script.
I have also copied the mysql-connector-java dir into WEB-INF/lib.
I have tried many of the other suggestions that I have found in this forum and elsewhere, but nothing seems to be doing the trick.
Any help would be greatly appreciated.
Reply With Quote
  #2  
Old 26th February 2006, 06:24 AM
Jman Offline
Registered User
 
Join Date: Mar 2004
Location: Minnesota, USA
Age: 27
Posts: 7,909
This seems to me to be the most important line:
Code:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
For some reason it's not finding the MySQL bindings. Your Class loading statment is exactly the same as your test class?
Reply With Quote
  #3  
Old 3rd April 2006, 11:21 AM
Coenos Offline
Registered User
 
Join Date: Apr 2006
Location: Vught
Age: 39
Posts: 14
same problem

Hi,

I have the same problem but then with the Oracle drivers. I added the JDBC drivers to the common/lib, shared/lib and <application>/WEB-INF/lib and nothing works.....

In your post you mention you have set the CLASSPATH in your Tomcat startup script. Which script is that and where is it located, as I have not done that config myself.

Thanks,
Coen
Reply With Quote
Reply

Tags
driver, mysql, problem, tomcat

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql and tomcat installation manu_1987 Using Fedora 2 28th November 2008 11:06 PM
problem with Tomcat - Mysql application faith_me Servers & Networking 0 5th November 2008 10:32 AM
tomcat weird tomcat automount error rotts Servers & Networking 7 18th June 2008 02:21 PM
Mysql and Tomcat integration nrobison Servers & Networking 0 4th July 2006 07:39 PM
FC4, Tomcat & MySQL ConnectorJ and Java woes 8128davidh EOL (End Of Life) Versions 9 2nd August 2005 07:45 AM


Current GMT-time: 01:15 (Thursday, 23-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat