我想從java連接到MS SQL Server 2005,出現以下錯誤, 任何人都可以幫助我嗎?連接到Microsoft SQL Server時出錯
private static final String DRIVER_CLASS = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
Class.forName(DRIVER_CLASS);
DriverManager.getConnection("jdbc:sqlserver://localhost:1433","sa","root");
我增加了以下5個jar文件:
- msbase
- MSSQLSERVER
- msutil
- sqljdbc
- sqljdbc4
這位前ception是:
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)
不,我沒有任何防火牆 – 2010-02-04 11:45:02
檢查http://support.microsoft.com/kb/313178 – Lombo 2010-02-04 12:04:04
此線程也有一些可能的答案http://forums.sun.com/thread.jspa?threadID=419214 – Lombo 2010-02-04 12:07:39