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.


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

...全文
67 点赞 收藏 11
写回复
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
自己顶
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告