MagicBoy 发表于 2005-3-18 13:24:17

slackware10下用jsp连接mysql5.0出现错误

jsp代码如下:
<%@ page contentType="text/html;charset=gbk"%>
<%@ page import="java.sql.*"%>
<html>
<title>测试数据库</title>
<body>
<%
out.println("测试数据库");

try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();

}
catch (Exception E) {
out.println("Unable to load driver.");

}

try {
Connection C = DriverManager.getConnection("jdbc:mysql://localhost/netshop?user=mysql&password=&useUnicode=true&characterEncoding=8859_1");
Statement s=C.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=s.executeQuery("select * from shop_admin");
out.println("<table border=1>");
int i=1;
for (i=10;i<20;i++)
{
if (rs.absolute(i))
{
out.println("<tr><td>");
out.println(rs.getString(1));
out.println("</td>");
out.println("<td>");
out.print(rs.getString(2));
out.println("</td>");
out.println("<td>");
out.print(rs.getString(3));
out.println("</td></tr>");
}
else
{
break;
}

}
out.println("</table>");
rs.close();
s.close();
C.close();


}
catch (SQLException E) {
out.println("SQLException: " + E.getMessage());
out.println("SQLState: " + E.getSQLState());
out.println("VendorError: " + E.getErrorCode());
}

%>
</body>
</html>



出现的错误页面如下:测试数据库
SQLException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.io.EOFException STACKTRACE: java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1895) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2342) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2838) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:773) at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3612) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1204) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1699) at com.mysql.jdbc.Connection.(Connection.java:408) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:270) at java.sql.DriverManager.getConnection(DriverManager.java:525) at java.sql.DriverManager.getConnection(DriverManager.java:193) at org.apache.jsp.connmysql_jsp._jspService(org.apache.jsp.connmysql_jsp:61) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) ** END NESTED EXCEPTION ** SQLState: 08S01 VendorError: 0

各位前辈,我这个问题弄了很久都没有办法解决阿!
页: [1]
查看完整版本: slackware10下用jsp连接mysql5.0出现错误