| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 731 人关注过本帖
标题:求助:jdbc连接
取消只看楼主 加入收藏
cyinfinite
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2004-12-4
收藏
 问题点数:0 回复次数:1 
求助:jdbc连接

<%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%> <html> <body> <%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test"; //user,password 分别为数据库的用户名及密码 String user="sa"; String password="sa"; Connection conn=DriverManager.getConnection(url,user,password); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from userinfo"; ResultSet rs=stmt.executeQuery(sql); while(rs.next()) {%> 您的第一个字段内容为:<%=rs.getString(1)%><br> 您的第二个字段内容为:<%=rs.getString(2)%><br> 您的第三个字段内容为:<%=rs.getString(3)%><br> <%}%> <%out.print("数据库连接成功!!!");%> <%rs.close(); stmt.close(); conn.close(); %> </body> </html>

异常如下,请问怎么解决呢?

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.t1_jsp._jspService(t1_jsp.java:77)
	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(Unknown Source)
	java.sql.DriverManager.getConnection(Unknown Source)
	org.apache.jsp.t1_jsp._jspService(t1_jsp.java:47)
	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.

搜索更多相关主题的帖子: jdbc 
2005-04-20 22:58
cyinfinite
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2004-12-4
收藏
得分:0 
嘿嘿,重装数据库就可以了~多谢各位。。。
2005-04-22 14:49
快速回复:求助:jdbc连接
数据加载中...
 
   



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

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