sqlserver2000连接异常

pengpeng11 2008-05-30 09:22:56
我sqlserver2000已经打上了sp4的补丁,但在进行JDBC连接时还是抛出了如下异常,请哪位大哥帮我看下,如何解决,谢谢!
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.cityinfo.dao.Test.main(Test.java:20)
...全文
64 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
siyue_qi 2008-05-30
  • 打赏
  • 举报
回复
cmd---> netstat -a
看看1433端口开了没?
pengpeng11 2008-05-30
  • 打赏
  • 举报
回复
相关jar都加入到了lib下了,
<code>
package com.cityinfo.dao;

import java.sql.*;

public class Test
{
public static void main(String[] args)
{
String DriverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; //定义数据库的驱动
String DBurl = "jdbc:microsoft:sqlserver://localhost:1433;DataBaseName=db_CityInfo"; //定义数据库连接
Connection conn = null; //声明数据库连接
Statement stmt = null;
ResultSet rs = null;
String user = "sa";
String password = "sa";

try
{
Class.forName(DriverName);
conn = DriverManager.getConnection(DBurl,user,password);
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from tb_info");
while(rs.next())
{
System.out.println(rs.getString("name"));
}
}
catch(ClassNotFoundException e)
{
e.printStackTrace(); //将exception写入log4j的日志文件中
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs= null;
}
if(stmt !=null)
{
stmt.close();
stmt=null;
}
if(conn != null)
{
conn.close();
conn=null;
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
}
</code>
chjx1982 2008-05-30
  • 打赏
  • 举报
回复
连接类贴出来看看.
jastby 2008-05-30
  • 打赏
  • 举报
回复
有没有开启防火墙的? 如果有 关闭防火墙 试试

检查下 链接字符串 的 数据库地址 端口 用户 密码 数据库名称 是否正确
pingfan520 2008-05-30
  • 打赏
  • 举报
回复
是否把sqlserver2000的驱动拷贝到了lib目录下?

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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