当前位置: 代码迷 >> J2SE >> 没有连上sqlServer2000,请高手帮助解决思路
  详细解决方案

没有连上sqlServer2000,请高手帮助解决思路

热度:188   发布时间:2016-04-24 13:21:11.0
没有连上sqlServer2000,请高手帮助
我应经在lomboz eclipse 里加上了external archives;
而且装了sqlserver2000 for jdbc的补丁;
import java.sql.*;

public class TestDB {
  public static void main(String[] args) {
  String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
  String dbURL = "jdbc:microsoft:sqlserver://192.168.1.24:1433;DatabaseName=pubs";
  String userName = "sa";
  String userPwd = "";
  Connection dbConn;
  try {
  Class.forName(driverName);
  dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
  System.out.println("Connection Successful!");
  }
  catch (Exception e) {
  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 TestDB.main(TestDB.java:12)


------解决方案--------------------
打了补丁没有,查看一下1433端口是否打开,在命令窗口下输入
netstat -an看看有没有1433
  相关解决方案