这几天我一头雾水搞不清楚为什么,我用的是XP系统,TOMCAT5.0服务器,JDBC 用的是SQL Server 2000 Driver for JDBC Service Pack 3,可连接SQLServer 2000 时老连不上出现[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.错误,请求高手帮助,非常感谢!!!
代码如下:
import java.sql.*;
import java.io.*;
public class test
{
    public  static void main(String arg[]) throws Exception{
        Connection con=null;
   try{
     Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
     con=DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433","sa","123456");
     CallableStatement stmt=con.prepareCall("{call sp_adduser(?,?,?,?)}");
     stmt.registerOutParameter(4,Types.INTEGER,1);
     stmt.setString(1,"小红");
     stmt.setInt(2,2);
     stmt.setString(3,"小李你好");
     stmt.execute();
     int userid=stmt.getInt(4);
     stmt.close();
     System.out.println("输出的用户ID是:"+ userid);
    }catch(ClassNotFoundException e){
     System.out.println("class not finded");
   }catch(SQLException e){
   System.out.println(e.getMessage());
   }finally{
      try{
        if(con!=null) con.close();      }catch(Exception e){
      }
   }
  }
}