各位大侠来帮忙:SqlServer2000连接问题!!急!急!!!在线等!!!

四流程序员的业余生活 2011-05-02 01:19:08
我的代码是:

package com.schoolmate.entity;
import java.sql.*;
public class Number {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=schoolmate";
String user="sa";
String password="sa";
String sql="select * from administrator;";
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
System.out.println("创建连接对象成功");
//com.microsoft.jdbc.sqlserver.
Connection conn= DriverManager.getConnection(url,user,password);
System.out.println("成功");
java.sql.Statement stmt=conn.createStatement();
System.out.println("创建statement成功");
ResultSet rs=stmt.executeQuery(sql);
System.out.println("操作数据成功");
while(rs.next())
{
System.out.println("连接成功");
}

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

结果是:创建连接对象成功
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.schoolmate.entity.Number.main(Number.java:36)


该导的包啊什么的我都导了(如图:),sp3 sp4补丁我都打在那个安装目录下了,可还是不行。
...全文
64 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangsheng281 2011-05-02
  • 打赏
  • 举报
回复
自问自答方式很好。
claro 2011-05-02
  • 打赏
  • 举报
回复
自问自答方式很好。
qgfudi 2011-05-02
  • 打赏
  • 举报
回复
接上楼,应该是高兴吧?
qgqch2008 2011-05-02
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 fredrickhu 的回复:]
引用 1 楼 ashi198866 的回复:
已解决!!!!!!

GX
[/Quote]GX是什么意思?
--小F-- 2011-05-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 ashi198866 的回复:]
已解决!!!!!!
[/Quote]
GX
  • 打赏
  • 举报
回复
已解决!!!!!!

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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