| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1416 人关注过本帖
标题:JSP连接SQL Server 2000的问题,总是连不上!
只看楼主 加入收藏
林中剑影
Rank: 1
来 自:广州
等 级:新手上路
帖 子:91
专家分:0
注 册:2007-11-3
收藏
 问题点数:0 回复次数:3 
JSP连接SQL Server 2000的问题,总是连不上!
JSP连接SQL Server 2000的问题,总是连不上。
我这边的开发工具是:MyEclipse+Tomcat5.5.20,JSP那些页面都能打开,就是连不了SQL Server 2000,那个SQL Server 2000安装的时候没有设置什么密码,怎么就连接不上呢,晕啊,搞了我几天还不行,数据库都重装了几次了:
下面是简单的代码,大家帮我测试一下 好吗?
<%@page import="java.lang.*, *, java.sql.*, java.util.*" contentType="text/html;charset=gb2312"%>
<html>
<body>
<%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=ShareResource";
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from student";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){ %>
您的第一个字段内容为:<%=rs.getString(1)%><br>
您的第二个字段内容为:<%=rs.getString(2)%><br>
<%}%>
<%out.print("数据库连接成功,恭喜你");%>
<%
rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

在浏览器中的错误提示:
HTTP Status 500 -

type Exception report

message

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

exception

org.apache.jasper.JasperException: Exception in JSP: /sql.jsp:8

5: String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=ShareResource";
6: String user="sa";
7: String password="";
8: Connection conn= DriverManager.getConnection(url,user,password);
9: Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
10: String sql="select * from student";
11: ResultSet rs=stmt.executeQuery(sql);


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
    org.apache.jsp.sql_jsp._jspService(sql_jsp.java:86)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

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.<init>(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:525)
    java.sql.DriverManager.getConnection(DriverManager.java:171)
    org.apache.jsp.sql_jsp._jspService(sql_jsp.java:53)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

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

[[it] 本帖最后由 林中剑影 于 2008-1-29 13:04 编辑 [/it]]
搜索更多相关主题的帖子: SQL Server JSP 数据库 java 
2008-01-29 12:59
hwoarangzk
Rank: 4
来 自:冰封王座
等 级:贵宾
威 望:12
帖 子:1894
专家分:0
注 册:2007-7-17
收藏
得分:0 
打补丁没?

I'm here, as always...
2008-01-29 14:41
林中剑影
Rank: 1
来 自:广州
等 级:新手上路
帖 子:91
专家分:0
注 册:2007-11-3
收藏
得分:0 
现在成功了,原来是补丁的问题呀,谢谢了!

好好学习,天天向上!
2008-01-29 14:43
czpae86
Rank: 1
来 自:广东佛山
等 级:新手上路
帖 子:32
专家分:0
注 册:2008-1-31
收藏
得分:0 
很简单的嘛!康康先生!
2008-01-31 16:23
快速回复:JSP连接SQL Server 2000的问题,总是连不上!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029654 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved