User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 427,744 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,878 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 7253 | Replies: 3
Reply
Join Date: Feb 2006
Posts: 2
Reputation: rev4eva is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
rev4eva rev4eva is offline Offline
Newbie Poster

Problem connecting my Tomcat Server and MySQL using JSP

  #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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 3
Reputation: sangamesh is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sangamesh sangamesh is offline Offline
Newbie Poster

Re: Problem connecting my Tomcat Server and MySQL using JSP

  #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  
Join Date: Feb 2006
Posts: 2
Reputation: rev4eva is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
rev4eva rev4eva is offline Offline
Newbie Poster

Re: Problem connecting my Tomcat Server and MySQL using JSP

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

Re: Problem connecting my Tomcat Server and MySQL using JSP

  #4  
Feb 13th, 2006
ok bye.....
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 12:45 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC