为什么我从Apache Derby收到这些错误? [英] Why am I getting these errors from Apache Derby?

查看:126
本文介绍了为什么我从Apache Derby收到这些错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行我的程序,数据库被连接,然后给我两个错误。一个说法

 'SchemaROOT不存在'

另一句话

 '第1行第8列的词汇错误遇到:@(64),之后:。 

这是两条SQL语句中的代码:

  private void UpdateJTable(){
String sql =select idhonscores AS RowNo,Name,Characters,Kills,Deaths,Assists,XPM,CK from honscores;
try {
st = conn.prepareStatement(sql);
rs = st.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));

} catch(Exception e){
JOptionPane.showMessageDialog(null,e);
}
}

这是从第一个错误和

  String sql3 =SELECT+@ rn:= @ rn + 1+AS Rank,Name,Kills 
FROM (选择名称,总和(杀死)作为杀死
从Honscores组按名称命令杀死DESC)t1,
(SELECT+@ rn:= 0+)t2;;

是第二个错误

解决方案


  1. 在derby中,默认模式始终是用于创建jdbc连接的用户的模式。我不能从你的问题中得知,你如何初始化和设置derby数据库。但是,将$ code>; create = true 添加到jdbc-url可能会有所帮助(如果不存在,则会创建数据库和模式)。

您可以更改执行:

  SET SCHEMA MYSCHEMA; 




  1. @ -syntax在derby中可能不可用。不是在另一个数据库中工作的所有内容(特别是如果它是特定于db的)将在德比工作。


I run my program, the database is connected to and then it gives me two errors. One saying

'Schema "ROOT" does not exist' 

and another saying

'Lexical error at line 1, column 8. Encountered: "@"(64), after:"".

Here is the code from the two SQL statements:

private void UpdateJTable() {
    String sql ="select idhonscores AS RowNo , Name, Characters, Kills, Deaths, Assists, XPM, CK from honscores";
    try {
        st = conn.prepareStatement(sql);
        rs = st.executeQuery();
        table.setModel(DbUtils.resultSetToTableModel(rs));

    } catch(Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }
}

That is from the first error and

String sql3 ="SELECT "+"@rn:=@rn+1"+" AS Rank, Name, Kills 
              FROM (Select Name, sum(Kills) as Kills 
                    from honscores group by Name order by Kills DESC) t1,
                   (SELECT "+"@rn:=0"+") t2;";

Is for the second error

  1. In derby the default schema is always the schema of the user you use to create the jdbc connection. I can't tell from you question, how you initialize and setup the derby database. But appending ;create=true to the jdbc-url might help (this will create the db and schema if it does not exist).

You can change to a different schema by executing:

SET SCHEMA MYSCHEMA;

  1. The @-syntax might not be available in derby. Not everything that works in another db (especially if it is db specific) will work in derby.

这篇关于为什么我从Apache Derby收到这些错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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