JDBC嵌入式Derby:找不到合适的驱动程序 [英] JDBC embedded Derby: No suitable driver found

查看:75
本文介绍了JDBC嵌入式Derby:找不到合适的驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写带有嵌入式Derby的程序,但是当我运行它时,它显示:

I'm trying to write a program with embedded Derby, but when I run it, it displays:

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之后的列应替换为分号.

the column after gdtu should be replaced with semicolon.

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

这篇关于JDBC嵌入式Derby:找不到合适的驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆