gpt4 book ai didi

java - JDBC嵌入式Derby : No suitable driver found

转载 作者:行者123 更新时间:2023-12-02 02:42:58 29 4
gpt4 key购买 nike

我正在尝试编写一个带有嵌入式 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);
}


}

}
}

最佳答案

gdtu 后面的栏应替换为分号。

private static final String JDBC_URL = "jdbc:derby:gdtu;create=true";

关于java - JDBC嵌入式Derby : No suitable driver found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45111301/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com