473,326 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Servlet SQLException Communication link failure

15
Servlet SQLException Communication link failure java howto



i can't connect jsp and database(mysql).
This is the exception:


exception
org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input stream

** BEGIN NESTED EXCEPTION **

java.io.IOException
MESSAGE: Unexpected end of input stream

STACKTRACE:

java.io.IOException: Unexpected end of input stream
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:109 6)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:62 6)
at com.mysql.jdbc.Connection.createNewIO(Connection.j ava:1562)
at com.mysql.jdbc.Connection.<init>(Connection.java:4 91)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:346)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.apache.jsp.audio_jsp._jspService(audio_jsp.jav a:108)
at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:390)
at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:212)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:445)
at java.lang.Thread.run(Unknown Source)


** END NESTED EXCEPTION **


org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:414)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
Mar 23 '07 #1
7 3562
sicarie
4,677 Expert Mod 4TB
What version of JDBC driver are you using?
Mar 23 '07 #2
bylum
15
What version of JDBC driver are you using?
i use mysql-connector-java-3.0.8-stable-bin.jar version of JDBC and
com.mysql.jdbc.Driver
Mar 24 '07 #3
sicarie
4,677 Expert Mod 4TB
i use mysql-connector-java-3.0.8-stable-bin.jar version of JDBC and
com.mysql.jdbc.Driver
Did you recently upgrade? Are you sure the driver is set correctly in the Classpath?

I found this on MySQL's site.
Mar 24 '07 #4
bylum
15
Did you recently upgrade? Are you sure the driver is set correctly in the Classpath?

I found this on MySQL's site.
i set the classpath =
C:\Program Files\Java\jdk1.6.0\jre\lib\ext\mysql-connector-java-5.0.4-bin.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\mysql-connector-java-3.0.8-stable-bin.jar;
Mar 24 '07 #5
sicarie
4,677 Expert Mod 4TB
i set the classpath =
C:\Program Files\Java\jdk1.6.0\jre\lib\ext\mysql-connector-java-5.0.4-bin.jar;C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib\mysql-connector-java-3.0.8-stable-bin.jar;
Hmmm, I guess what process did you use to initiate the connection?

(ie, used classforname to register the driver, created the con, created statement, etc...)
Mar 24 '07 #6
bylum
15
Hmmm, I guess what process did you use to initiate the connection?

(ie, used classforname to register the driver, created the con, created statement, etc...)

this is my coding..

<%
String connectionURL = "jdbc:mysql://localhost:3306/webaudio?user=root";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<html>
<head></head>
<body>
<table>
<tr align="center"><td align="center">
<%
Class.forName("com.mysql.jdbc.Driver").newInstance ();
connection = DriverManager.getConnection(connectionURL, "root", "123");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT name FROM audio");

out.println("<table border=1>");
out.println("<tr><td>Audio In Database</td></tr>");

while (rs.next())
{
out.println("<tr><td>");
String file = rs.getString("name");
if((file!=null))
{
out.println("<a href=rtsp://554@localhost/test/" + file + ">");
out.println(file + "<br>");
out.println("</a></td></tr>");
}
}
out.println("</table>");

rs.close();
%>
</td>></tr>
</table>
</body>
<html>
Mar 24 '07 #7
sicarie
4,677 Expert Mod 4TB
Using code tags helps the readability.

So there are two things that I have seen:
1) no try-catch. Lots of compilers will complain about this - but this also looks like javascript, which I know absolutely nothing about, so I could be wrong.

2) on the code below, you use file!=null, and Java string comparisons should be done with String.equals(); - in your case file.equals(null), and then a not around that.
Expand|Select|Wrap|Line Numbers
  1. String file = rs.getString("name");
  2. if((file!=null))
  3. {
  4.     out.println("<a href=rtsp://554@localhost/test/" + file + ">");
  5.     out.println(file + "<br>");
  6.     out.println("</a></td></tr>");
  7. }
  8.  
Try at least changing the second - I'm pretty sure that would throw an IOException.
Mar 24 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: BryarWoilf | last post by:
Hi all, I'm still somewhat new to servlet/JSP programming, but I want to my application to use the MVC model. I have some simple JSP pages that dynamically open an applet that the user uses...
3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
2
by: neo | last post by:
Hi, with SQL 2000 and Windows 2000, we're getting lots of this error message "Communication link failure" from our C++ application. Any idea why? Thanks,
1
by: Pavel Vetesnik | last post by:
Hello, We are the authors of an application written in PowerBuilder (type Client-Server, database MSSQLServer2000). After some time (1 hour) of client inactivity happens disconnect from server...
1
by: Nick Nygaard | last post by:
Hi everyone, I'm using O'Reilly's servlet API to make an object based HTTP communication between an Applet and a servlet. Following their own tutorial 10.2.3. Object-based HTTP Communication...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
6
by: santhoskumara | last post by:
How to request to servlet from Ajax and also I got the DOM object in the servlet through Business Logic. Now how will i pass the DOM object from serlvet to Clientside. Where in the client Side i am...
2
by: dmstn | last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in...
2
by: ManidipSengupta | last post by:
Hi, a few (3) questions for the Java experts, and let me know if this is the right forum. It deals with 100% java code (reason for posting here) but manages a Web browser with Javascript. Thanks in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.