急,各位大哥帮帮忙吧,Java 连接SQLServer问题
public static Connection acquireConnection(String host,String port,String dbName,
String user,String pwd) throws ClassNotFoundException,SQLException{
Connection connection=null;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url ="jdbc:microsoft:sqlserver://"+
host+":"+port+";User="+user+";Password="+pwd;
connection= DriverManager.getConnection(url);
connection.setCatalog(dbName);
}catch(ClassNotFoundException e){
e.printStackTrace();
throw e;
}catch(SQLException e){
e.printStackTrace();
throw e;
}
return connection;
}
通过上面的代码访问SQL数据库,总是抛出下面一段异常
java.Sql.SqlException :[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing
socket. at
com.microsoft.jdbc.base.BaseException.createException<UnknownSourse>
...
请教各位大哥怎么才能成功连接