【发布时间】:2017-12-20 01:07:23
【问题描述】:
我正在尝试使用嵌入式 Derby 编写程序,但是当我运行它时,它会显示:
run:
Jul 14, 2017 9:19:54 PM gfdh.Login Doconnect
SEVERE: null
java.sql.SQLException: No suitable driver found for jdbc:derby:gdtu:create=true
...
代码:
public class Login extends javax.swing.JFrame {
Connection con;
Statement stmt;
ResultSet rs;
private static final String DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
private static final String JDBC_URL = "jdbc:derby:gdtu:create=true";
public Login(){
initComponents();
Doconnect();
}
private void Doconnect(){
try {
this.con = DriverManager.getConnection(JDBC_URL);
if(this.con != null){
System.out.println("Connected to database");
}
} catch (SQLException ex) {
Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
【问题讨论】:
-
您的 CLASSPATH 中有 derby.jar 吗?如果没有,请添加它。
标签: java jdbc netbeans derby embedded-database