为什么 我的程序连接不了 SQLSERVER 数据库 ?????
出错提示:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
代码如下:
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver ";
String dbURL = "jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=ifax ";
String userName = "sa ";
String userPwd = "1 ";
Connection dbConn;
Statement sta;
ResultSet rs;
try{
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
String sql = "select * from card ";
sta = dbConn.createStatement();
rs = sta.executeQuery(sql);
}
catch (Exception e)
{
System.out.print(e.toString());
}
}
------解决方案--------------------是用JB做的吧!
JB里没有这个驱动,最好在网上找一个,放在LIB文件里,就能认得这个驱动了