为什么我从 Apache Derby 收到这些错误?
我运行我的程序,连接数据库,然后它给我两个错误。一种说法
'Schema "ROOT" does not exist'
和另一种说法
'Lexical error at line 1, column 8. Encountered: "@"(64), after:"".
下面是两个 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);
}
}
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
;create=true
附加到 jdbc-url 可能会有所帮助(如果数据库和模式不存在,这将创建它)。来更改为不同的架构:
;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:
关于用户名是默认模式的说法是正确的。如果您不指定用户名,则默认架构将为 APP。这个模式总是存在的。如果您以 root 用户身份连接,则在您在其中创建表之前不会创建模式“root”。例如:
Wrt。表名和列名中的@:仅当引用包含@的名称时才允许这样做。例如:
但请注意,引用名称时区分大小写。因此,在前面的示例中,以下操作失败:
因为在引号中,@T@ 和 @t@ 被视为不同的名称。
What has been said about username being the default schema is true. If you do not specify a username the default schema will be APP. This schema always exists. If you connect as user root the schema "root" will not be created until you create a table in it. E.g:
Wrt. @ in table and column names: That is only allowed if you quote the name containing @. E.g.:
Note however, that when quoting a name it becomes case-sensitive. So in the previous example the following fails:
because in quotes, @T@ and @t@ are considered different names.