我的系统是windows server 2003
数据库是sql server 2000
已经安装了一个Microsoft SQL Server 2000 Driver for JDBC
然后已经把msbase.jar mssqlserver.jar msutil.jar 三个文件放到j2sdk的lib下了.我用一个JCreator 写一个连接数据库的程序.程序如下:
import java.sql.*;
public class DTool{
//Connection conn;
public static void main(String[] args) {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs","sa","123");
System.out.println("连接成功!");
}
catch(Exception e){
e.printStackTrace();
}
}
}
编译时没错,可运行时出现如下错误:
--------------------Configuration: <Default>--------------------
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(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at DTool.main(DTool.java:8)
Process completed.
请大家帮忙一下,,怎么解决,,是不是我配置的时个哪里弄错了,,我搞这个问题好久了,,可都没弄好,,也按照网上的说去弄了,还是不行~~~~跪地求了~~~
------解决方案--------------------
配置应该没问题 是你的数据库有问题
------解决方案--------------------
打上数据库SP3补丁应该就可以解决了