com.microsoft.sqlserver.jdbc.SQLServerException: Unrecognized Windows Sockets error: 997: recv failed
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSChannel.read(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at com.newer.efcms.dao.BaseDAO.getConnection(BaseDAO.java:39)

解决方案 »

  1.   

    我写了一段能够正确连接SQL数据库的代码!
    public class SqlTest { public static void main(String[] args) { 
    Connection connection = null; 
    Statement statement = null; 
    ResultSet resultSet = null; 
    String urlString = "jdbc:sqlserver://localhost:1433;DatabaseName=efcms"; 
    String user = "sa"; 
    String pwd = ""; 
    String sql = "select * from USERS"; 
    try { 
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver") 
    .newInstance(); 
    connection = DriverManager.getConnection(urlString, user, pwd); 
    statement = connection.createStatement(); 
    resultSet = statement.executeQuery(sql); 
    while (resultSet.next()) { 
    System.out.println(resultSet.getString("userID")); 

    } catch (Exception e) { 
    e.printStackTrace(); 
    } finally { 
    try { 
    resultSet.close(); 
    statement.close(); 
    connection.close(); 
    } catch (SQLException e) { 
    e.printStackTrace(); 




      

  2.   

    连接之前先"\\数据库IP地址"访问下数据库服务器
    记得以前SQL Server有这个毛病
      

  3.   

    可能是其他程序影响sql server 2005 的连接。比如上网的客户端等~~
      

  4.   

    DR.com会影响,但还不知道如何解决呢