数据库连接错误
public connectDB() {
String user = "sa";
String password = "";
//com.microsoft.jdbc.sqlserver.SQLServerDriver
String url ="jdbc:sun:sqlserver://192.168.1.6:1433;DatabaseName=test";
try {
Class.forName("com.sun.sql.jdbc.sqlserver.SQLServerDriver");
conn = DriverManager.getConnection(url,user,password);
} catch(Exception e) {
System.out.println("驱动程序加载异常" + e);
}
}
public ResultSet getAll() {
ResultSet rs = null;
Statement stmt = null;
try{
// System.out.println("出错2");
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from user1");
}
catch(SQLException e){
System.out.println("出错111");
System.out.println(e);
}
return rs;
}
错误信息:::
[#|2005-05-17T17:02:42.703+0800|信息|sun-appserver-pe8.0.0_01|javax.enterprise.system.stream.out|_ThreadID=12;|
java.sql.SQLException: [sunm][SQLServer JDBC Driver]This driver is locked for use with embedded applications.
用sun和microsoft提供的驱动都是出现同样的错误。
问题点数:30、回复次数:8Top
1 楼skycncomp(闭关修练到年底)回复于 2005-05-17 17:12:41 得分 0
stmt = conn.createStatement();这句出错。Top
2 楼newmeteor(圆缘)回复于 2005-05-17 17:20:38 得分 8
没有遇到过!帮你顶一下!继续偷学!Top
3 楼banquet(Everything will be well)回复于 2005-05-17 17:55:06 得分 5
顶一下Top
4 楼cslyaoyao(笑对人生)回复于 2005-05-17 18:13:45 得分 7
你应该拿完全点的程序来,这一小段不好看懂你是怎么用的,怎么出错的?Top
5 楼skycncomp(闭关修练到年底)回复于 2005-05-18 08:42:22 得分 0
我编译都不能通过的.
不知道是什么问题.Top
6 楼tys1105(想飞的鸟)回复于 2005-05-18 09:19:01 得分 5
检查一下你的classpath设置。Top
7 楼grzhenchun()回复于 2005-05-18 11:01:55 得分 5
没办法了,程序是没有问题的
主要看看你的classpathTop
8 楼skycncomp(闭关修练到年底)回复于 2005-05-19 11:25:06 得分 0
classpath肯定是没有任何问题的.
我怀疑是不是网络的问题.或者是防火墙的问题.Top




