Problem connecting my Tomcat Server and MySQL using JSP
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Revathi_Subramaniam
Posted On:   Tuesday, February 7, 2006 01:22 PM

My Query Details Problem connecting my Tomcat Server and MySQL using JSP I have tried to connect my JSP codes to my database server but i seem to get an error saying that it cannot locate the driver. My normal java codes to retrieve data frm database works fine but not my JSP codes. I m a bit lost in the configuration matter. Can someone plz help me. I m using Netbeans 3.6, jakarta-Tomcat-5.0.25 and MySQL 5.0.16-nt . I have enclosed my error and my codes. <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@page import="java.sql.Connection"%> <%@page import="java.sql.DriverManager"%>    More>>
My Query Details

Problem connecting my Tomcat Server and MySQL using JSP



I have tried to connect my JSP codes to my database server but i seem to get an error saying that it cannot locate the driver. My normal java codes to retrieve data frm database works fine but not my JSP codes. I m a bit lost in the configuration matter. Can someone plz help me.
I m using Netbeans 3.6, jakarta-Tomcat-5.0.25 and MySQL 5.0.16-nt . I have enclosed my error and my codes.

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

<%@page import="java.sql.Connection"%>

<%@page import="java.sql.DriverManager"%>

<%@page import="java.sql.SQLException"%>

<%@page import="java.sql.* "%>








My Query Details









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

Connection myConn = DriverManager.getConnection("jdbc:mysql:://localhost/githika?user=root");

Statement stmt = myConn.createStatement();
ResultSet myResultSet = stmt.executeQuery("select * from exercise");


if (myResultSet != null) {

while (myResultSet.next()) {

String name = myResultSet.getString("Name");

String id = myResultSet.getString("ID");

%>






<%
}//end of while
}//end of if

stmt.close();

myConn.close();

%>
Name ID
<%= name %> <%= id %>







HTTP Status 500 -

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: No suitable driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.dbquery_jsp._jspService(dbquery_jsp.java:97)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:305)
root cause
java.sql.SQLException: No suitable driver
java.sql.DriverManager.getConnection(DriverManager.java:545)
java.sql.DriverManager.getConnection(DriverManager.java:193)
org.apache.jsp.dbquery_jsp._jspService(dbquery_jsp.java:63)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:305)
note The full stack trace of the root cause is available in the Tomcat logs.

   <<Less

Re: Problem connecting my Tomcat Server and MySQL using JSP

Posted By:   Jouko_Johansson  
Posted On:   Tuesday, February 7, 2006 02:39 PM

Please check that you have mysql drivers on your classpath.


You can copy it in your webapps's lib-directory or directly under the tomcat/commons/lib -directory
About | Sitemap | Contact