错误是java.sql.SQLSyntaxErrorException:模式'ROOT'不存在 [英] Error is java.sql.SQLSyntaxErrorException: Schema 'ROOT' does not exist

查看:671
本文介绍了错误是java.sql.SQLSyntaxErrorException:模式'ROOT'不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建使用derby嵌入式数据库的桌面应用程序,尽管当我将derby用作客户端数据库时它可以正常工作,但是我想将此数据库与我的桌面应用程序一起嵌入然后会引发错误 下面是帮助代码,请查看

i am creating desktop application which uses derby embedded database, although when i use derby as a client database then it works fine, but i want to embed this database with my desktop application then it throws error below is the code for help, check it out

public class TaxInvoice extends javax.swing.JFrame {

 //String connectionurl = "jdbc:derby://localhost:1527/embdIDA1db";

 String connectionurl = "jdbc:derby:embdIDA1db;create=true;user=root;password=root";

 Connection conn = null; 

 ResultSet rs;

 String po_no = null;

/**
 * Creates new form TaxInvoice
 */
public TaxInvoice() {
    initComponents();
    String dt = sdf.format(cal.getTime());
    cur_date.setText(dt);
    try{
        Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
        conn = DriverManager.getConnection(connectionurl,"root","root");
        String sql="Select * from IMPORTED_CSV";
        Statement s = conn.createStatement();
        s.executeQuery(sql);
        rs = s.getResultSet();
        while(rs.next()){
            po_no = rs.getString("PO_NO");
            jTextField1.setText(po_no);
        }
        rs.close();
        s.close();
    }
    catch(Exception e){
        System.out.println("Error is"+e);
    }
}

,错误是

Error isjava.sql.SQLSyntaxErrorException: Schema 'ROOT' does not exist

推荐答案

您的connectionURl应该为jdbc:derby://localhost:1527/embdIDA1db,这似乎在您的代码中已被注释掉.

Your connectionURl should be jdbc:derby://localhost:1527/embdIDA1db which seems to be commented out in your code.

您正在显式传递用户名和密码,因此无需在url中包含它们.

Your are passing username and password explicitly so there is no need to include them in url.

DriverManager.getConnection(connectionurl,"root","root");

这篇关于错误是java.sql.SQLSyntaxErrorException:模式'ROOT'不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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