| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 598 人关注过本帖
标题:[求助]:各位大侠请帮帮小弟!!~~
取消只看楼主 加入收藏
2004110
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-6-4
收藏
 问题点数:0 回复次数:2 
[求助]:各位大侠请帮帮小弟!!~~
JSP在与sql server 2000 连接时我用的是下面的代码:

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%
//try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=yg";
//yg为我的数据库的
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
//Statement stmt=conn.createStatement();  
String sql="select * from users";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
               <%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
//}catch(Exception e){
//out.println(e);
//}
%>
</body>
</html>
2005-10-04 12:51
2004110
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-6-4
收藏
得分:0 
运行后出错:

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:825)	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)	org.apache.jsp._1_jsp._jspService(_1_jsp.java:90)	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)	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:512)	java.sql.DriverManager.getConnection(DriverManager.java:171)	org.apache.jsp._1_jsp._jspService(_1_jsp.java:54)	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

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

2005-10-04 12:52
2004110
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-6-4
收藏
得分:0 
jdbc 驱动和classpath都设好了!!
就是出现这样的错误:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
我搞了好几天了!!
2005-10-09 13:37
快速回复:[求助]:各位大侠请帮帮小弟!!~~
数据加载中...
 
   



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

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