java sql 框架,错误是java.sql.SQLSyntaxErrorException:架构'ROOT'不存在

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);

}

}

and the error is

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

解决方案

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

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值