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.* "%>


<html>
<head><title>My Query Details</title></head>


<body>
<h1> My Query Details </h1>
<table border='1' width="400">
<tr>
<td><b>Name</b></td><td><b>ID</b></td>
</tr>
<% 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");
%>
<tr>
<td><%= name %></td>
<td><%= id %></td>
</tr>
<%
}//end of while
}//end of if
stmt.close();
myConn.close();
%>
</table>
</body>
</html>
==============================================

The error message is :

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.

Edited 3 Years Ago by happygeek: fixed formatting

Hi,

I think the problem with your connection is with the url used in your program the url should be
jdbc:mysql://localhost:port/query
and also do check with the loading driver and for the jar file which should be placed in tomcat_home/common/lib.

Bye..............

This article has been dead for over six months. Start a new discussion instead.