jdbc 连接sql server2000 出现问题如下:
java.sql.SQLException:[Microsoft][SQLServer2000DriverforJDBC]Errorestablishingsocket....
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:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at conn.Conn.getCon(Conn.java:28)
at test.Test.main(Test.java:14)
链接失败
程序代码:
public Connection getCon()
{
try {
//加载驱动
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
//得到链接
String url="jdbc:microsoft:sqlserver://172.18.78.129:1433;DatabaseName=shopmanage";
con=DriverManager.getConnection(url,"huhao","123456");
//创建Statement
//stmt = con.createStatement();
System.out.println("链接成功");
return con;
} catch (Exception e) {
e.printStackTrace();
System.out.println("链接失败");
return null;
}
} 展开
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:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at conn.Conn.getCon(Conn.java:28)
at test.Test.main(Test.java:14)
链接失败
程序代码:
public Connection getCon()
{
try {
//加载驱动
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
//得到链接
String url="jdbc:microsoft:sqlserver://172.18.78.129:1433;DatabaseName=shopmanage";
con=DriverManager.getConnection(url,"huhao","123456");
//创建Statement
//stmt = con.createStatement();
System.out.println("链接成功");
return con;
} catch (Exception e) {
e.printStackTrace();
System.out.println("链接失败");
return null;
}
} 展开
2个回答
展开全部
看代码是没有什么问题的,而在看看你的错误,是指socket错误,也就是你的程序连接不到sql数据库,所以你首先看看你的数据库的url,端口有没有写错,没有的话,就可能是你的sql的问题,解决方法你上百度,将你的java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket这段东西复制上百度搜索,那就由很多结果的呢,我们写代码的不可能知道所有的exception怎么解决一般都是吧第一个exception的第一句话复制上百度然后搜索的,呵呵呵希望能帮得到你
TableDI
2024-07-18 广告
2024-07-18 广告
`VLOOKUP` 匹配出错误的数据通常是由于以下几个原因:1. **查找值错误**:输入的查找值与数据源中的值不匹配,可能是因为拼写错误、大小写不一致或存在不可见的字符。2. **查找区域设置错误**:查找区域的首列必须包含要查找的值,且...
点击进入详情页
本回答由TableDI提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询