Topic: Java程序连数据库的问题?

  Print this page

1.Java程序连数据库的问题? Copy to clipboard
Posted by: 迸泉
Posted on: 2005-11-17 16:00

try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
System.out.println("加载成功");
}
catch (Exception e) {
System.out.println("加载失败");
}
Connection con=null;
Statement stat=null;
ResultSet rs;
try{
String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=DangAnGuan";
con=DriverManager.getConnection(URL,"king","");
stat = con.createStatement();

}catch(SQLException e)
{
System.out.println("有问题");
e.printStackTrace();
}
这是我连接数据库中的一部分程序段。采取的是window身份认证,但运行以后爆出的是这样的错误:驱动加入应该成功了,因为没有爆出加载失败,而是加载成功。用户名,密码也应该没错,因为本人先前用jdbc:odbc桥连数据库成功了。不知道下面的错误是何故?
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)

2.Re:Java程序连数据库的问题? [Re: 迸泉] Copy to clipboard
Posted by: xrs
Posted on: 2005-12-03 00:22

SQLServer 2000 Driver for JDBC 不支持Windows身份认证,建议使用JTDS,很好用

3.Re:Java程序连数据库的问题? [Re: 迸泉] Copy to clipboard
Posted by: why
Posted on: 2005-12-03 20:48

Try to search on this board before you ask a question.
Please.

Yes, use jTDS if you could.

4.Re:Java程序连数据库的问题? [Re: 迸泉] Copy to clipboard
Posted by: Shincowang
Posted on: 2005-12-19 12:05

The database of DangAnGuan maybe doesn't exist!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923