QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1255|回复: 0

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

[复制链接]
发表于 2005-3-18 13:24:17 | 显示全部楼层 |阅读模式
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:283 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:40 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:17 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:14 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:73 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

各位前辈,我这个问题弄了很久都没有办法解决阿!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-16 19:02 , Processed in 0.227827 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表