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提供的驱动都是出现同样的错误。
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提供的驱动都是出现同样的错误。
主要看看你的classpath
我怀疑是不是网络的问题.或者是防火墙的问题.