943,681 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 10180
  • JSP RSS
Feb 8th, 2006
0

Problem connecting my Tomcat Server and MySQL using JSP

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rev4eva is offline Offline
2 posts
since Feb 2006
Feb 11th, 2006
0

Re: Problem connecting my Tomcat Server and MySQL using JSP

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..............
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sangamesh is offline Offline
3 posts
since Feb 2006
Feb 12th, 2006
0

Re: Problem connecting my Tomcat Server and MySQL using JSP

thanks alot. I got it working now. It was due to the driver.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rev4eva is offline Offline
2 posts
since Feb 2006
Feb 13th, 2006
0

Re: Problem connecting my Tomcat Server and MySQL using JSP

ok bye.....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sangamesh is offline Offline
3 posts
since Feb 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: Array String not working?
Next Thread in JSP Forum Timeline: How to MAKE a blog with java





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC