QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1909|回复: 5

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

[复制链接]
发表于 2005-3-18 13:24:33 | 显示全部楼层 |阅读模式
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

各位前辈,我这个问题弄了很久都没有办法解决阿!
请问是那里出了问题,怎么解决阿!
 楼主| 发表于 2005-3-18 13:40:23 | 显示全部楼层
大家帮帮忙阿! :-(  :-(  :-(  :-(  :-(  :-(  :-(
回复

使用道具 举报

发表于 2005-3-18 16:42:41 | 显示全部楼层
Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.io.EOFException

和MySQL的“交流”失败,因为出现了异常** BEGIN NESTED EXCEPTION ** java.io.EOFException

这个jsp编程错误需要你把JSP的应用掌握透哦
回复

使用道具 举报

 楼主| 发表于 2005-3-21 10:18:41 | 显示全部楼层
涩兔子
公社论坛版主
Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.io.EOFException

和MySQL的“交流”失败,因为出现了异常** BEGIN NESTED EXCEPTION ** java.io.EOFException

这个jsp编程错误需要你把JSP的应用掌握透哦

版主啊!能不能说下答案,我要的不是这个答案啊!!!我哭!!!!!!!!!
和MySQL的“交流”失败,因为出现了异常** BEGIN NESTED EXCEPTION ** java.io.EOFException
这个错误以前在windows下是没有问题的,在linux开发后,便有很大问题!
帮帮忙啊! :-(  :-(  :-(  :-(  :-(  :-(  :-(  :-(  :-(
回复

使用道具 举报

 楼主| 发表于 2005-3-22 08:37:16 | 显示全部楼层
搞定了,原来是我的用户名和密码问题而已,我真的很郁闷阿!!!! :-)  :-)  :-)  :-)  :-)
回复

使用道具 举报

发表于 2005-3-22 12:40:59 | 显示全部楼层
说明在Windows下没有设置用户名和密码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

© 2021 Powered by Discuz! X3.5.

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