100分 ==》请高手看看jsp+sql2000出了什么错误!

goslinggg 2004-10-04 11:59:16
源代码:(之后是错误代码)
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.io.*"%>
<html>
<body>
以下是从Ms sql server数据库读取的数据:<hr>
<table border=1>
<tr><td>id</td><td>书名</td><td>出版社</td><td>价格</td></tr>
<%! String trans(String chi)
{
String result = null;
byte temp [];
try
{
temp=chi.getBytes("iso-8859-1");
result = new String(temp);
}
catch(UnsupportedEncodingException e)
{
System.out.println (e.toString());
}
return result;
}
%>
<%

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection con=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jspdev","","");
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery("select * from book;");
while(rst.next())
{
out.println("<tr>");
out.println("<td>"+trans(rst.getString("bookId"))+"</td>");
out.println("<td>"+trans(rst.getString("bookName"))+"</td>");
out.println("<td>"+trans(rst.getString("publisher"))+"</td>");
out.println("<td>"+rst.getFloat("price")+"</td>");
out.println("</tr>");
}
//关闭连接、释放资源
rst.close();
stmt.close();
con.close();
%>
</table>
</body>
</html>


==========================================================================================
错误代码:

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.testMssql_jsp._jspService(testMssql_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
com.microsoft.jdbc.sqlserver.tds.TDSConnection.(Unknown Source)
com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
org.apache.jsp.testMssql_jsp._jspService(testMssql_jsp.java:64)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Tomcat logs.


谢谢各位了!!!!!!!

...全文
86 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
guojiafuzhuxi 2004-10-05
  • 打赏
  • 举报
回复
帮你顶!
朋友别哭 2004-10-05
  • 打赏
  • 举报
回复
一般sql2000数据库都有用户名的可能是"sa",密码不一定有.
你试试
nwpulipeng 2004-10-05
  • 打赏
  • 举报
回复
帮顶混分
moyachun 2004-10-05
  • 打赏
  • 举报
回复
我也遇到过类似的问题
真是太好了
fashchina 2004-10-05
  • 打赏
  • 举报
回复
你用的什么系统?
xp sp2就有上面的问题
装一下sql server sp3 就好了
梦想家起飞 2004-10-05
  • 打赏
  • 举报
回复
其实是因为mssql的jdbc驱动不匹配,你应该找一个完全和你现在使用的环境匹配的jdbc驱动。

扔掉mssql吧,搞java的哪有用它的?就算驱动的问题解决了,以后还有一大堆莫名其妙的问题等着你。
java悠悠 2004-10-05
  • 打赏
  • 举报
回复
你用的什么系统?
xp sp2就有上面的问题
装一下sql server sp3 就好了
goslinggg 2004-10-05
  • 打赏
  • 举报
回复
怎么配置服务器?
aleel008 2004-10-05
  • 打赏
  • 举报
回复
自己服务器配制的问题,代码上好像没有什么异常
smagt 2004-10-05
  • 打赏
  • 举报
回复
Error establishing socket
要么是数据库的端口不是1433,要么是服务器没开,连最基本的到服务器的连接都建立不起来
goslinggg 2004-10-04
  • 打赏
  • 举报
回复
自己顶

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧