当我尝试运行此程序时,出现此异常。这是微软的例子之一。我已经通过项目属性将sqljdbc4.jar添加到了netbeans的类路径中,以便进行编译和运行。我还测试了可以使用下面的import语句找到该类-编译期间没有错误,因此它必须找到jar。可能与sqldbc4.jar引用的dll或某些sql dll相关吗?这是确切的例外,下面是确切的代码(密码除外)。例外:run:java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://localhost:1433;databaseName=HealthCareDatabaseError Trace in getConnection() : No suitable driver found for jdbc:microsoft:sqlserver://localhost:1433;databaseName=HealthCareDatabaseError: No active Connection at java.sql.DriverManager.getConnection(DriverManager.java:602) at java.sql.DriverManager.getConnection(DriverManager.java:185) at javaapplication1.Connect.getConnection(Connect.java:35) at javaapplication1.Connect.displayDbProperties(Connect.java:50) at javaapplication1.JavaApplication1.main(JavaApplication1.java:23)BUILD SUCCESSFUL (total time: 1 second)码: package javaapplication1;import com.microsoft.sqlserver.jdbc.SQLServerDriver;import java.*;public class Connect { private java.sql.Connection con = null; private final String url = "jdbc:microsoft:sqlserver://"; private final String serverName = "localhost"; private final String portNumber = "1433"; private final String databaseName = "HealthCareDatabase"; private final String userName = "larry"; private final String password = "xxxxxxx"; // Constructor public Connect() { } private String getConnectionUrl() { return url + serverName + ":" + portNumber + ";databaseName=" + databaseName ; }
3 回答
- 3 回答
- 0 关注
- 865 浏览
添加回答
举报
0/150
提交
取消