Problem connecting my Tomcat Server and MySQL using JSP

Reply

Join Date: Feb 2006
Posts: 2
Reputation: rev4eva is an unknown quantity at this point 
Solved Threads: 0
rev4eva rev4eva is offline Offline
Newbie Poster

Problem connecting my Tomcat Server and MySQL using JSP

 
0
  #1
Feb 8th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 3
Reputation: sangamesh is an unknown quantity at this point 
Solved Threads: 0
sangamesh sangamesh is offline Offline
Newbie Poster

Re: Problem connecting my Tomcat Server and MySQL using JSP

 
0
  #2
Feb 11th, 2006
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..............
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2
Reputation: rev4eva is an unknown quantity at this point 
Solved Threads: 0
rev4eva rev4eva is offline Offline
Newbie Poster

Re: Problem connecting my Tomcat Server and MySQL using JSP

 
0
  #3
Feb 12th, 2006
thanks alot. I got it working now. It was due to the driver.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 3
Reputation: sangamesh is an unknown quantity at this point 
Solved Threads: 0
sangamesh sangamesh is offline Offline
Newbie Poster

Re: Problem connecting my Tomcat Server and MySQL using JSP

 
0
  #4
Feb 13th, 2006
ok bye.....
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC