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 423,134 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 4,162 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: 4851 | Replies: 13
Join Date: Mar 2007
Posts: 7
Reputation: A Yasir is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
A Yasir A Yasir is offline Offline
Newbie Poster

Please help me in connecting JSP to MySql

  #1  
Mar 29th, 2007
Hi ! I have a problem in connecting JSP pages with My SQL database using JDBC connector. I m using:
  • For TOMCAT -- apache-tomcat-5.5.23
  • For JRE -- Java EE 5 SDK
  • For database -- MySQL 5.0.37
  • For JDBC -- mysql-connector-java-3.0.17

JSP pages other than database working fine. I have copied mysql-connector-java-3.0.17-ga-bin.jar file in apache-tomcat-5.5.23\Tomcat 5.5\common\lib folder also for it. It is giving me error on connection line.

My Database structure is : Database: register, table: login, fields are: name, password, message.

I don’t know whether it’s a problem with compatibilities of different applications or there is something wrong with the code. Here is the code:

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

<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:8009/login? user=root&password=asma");
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("SELECT message FROM users");

while (rs.next()) {
out.println(rs.getString("message")+"<br>");
}

rs.close();statement.close();con.close();
%>

</body></html>

If anyone can help me I’ll be really greateful
And the error is :

HTTP Status 500 -


type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Exception in JSP: /connect1.jsp:63: 4: <%5: Class.forName("com.mysql.jdbc.Driver").newInstance();6: Connection con = DriverManager.getConnection("jdbc:mysql://localhost:8009/login? user=root&password=asma");7: Statement statement = con.createStatement();8: ResultSet rs = statement.executeQuery("SELECT message FROM users");9: Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:371) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)root cause
javax.servlet.ServletException: Communication link failure: java.io.EOFException, underlying cause: null** BEGIN NESTED EXCEPTION ** java.io.EOFExceptionSTACKTRACE:java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1395) at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:1414) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:625) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1808) at com.mysql.jdbc.Connection.<init>(Connection.java:452) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:411) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.apache.jsp.connect1_jsp._jspService(connect1_jsp.java:48) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685) at java.lang.Thread.run(Unknown Source)** END NESTED EXCEPTION ** org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779) org.apache.jsp.connect1_jsp._jspService(connect1_jsp.java:67) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



AddThis Social Bookmark Button
Reply With Quote  

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 7:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC