[英]Queries in Derby Embedded Database
我試過這個查詢
String sql1="select * from custinf";
try {
stmt=conn.createStatement();
stmt.execute(sql1);
stmt.close();
} catch (SQLException ex) {
Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
}
它拋出
java.sql.SQLSyntaxErrorException: Table/View 'CUSTINF' does not exist.
at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.ClientStatement.execute(Unknown Source)
at com.atuts.cms.database.Database.addCustomer(Database.java:57)
at com.atuts.cms.database.Database.main(Database.java:31)
Caused by: ERROR 42X05: Table/View 'CUSTINF' does not exist.
at org.apache.derby.client.am.ClientStatement.completeSqlca(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.parsePrepareError(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.parsePRPSQLSTTreply(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
at org.apache.derby.client.am.ClientStatement.readPrepareDescribeOutput(Unknown Source)
at org.apache.derby.client.am.ClientStatement.flowExecute(Unknown Source)
at org.apache.derby.client.am.ClientStatement.executeX(Unknown Source)
... 3 more
當我將查詢更改為String sql1="select * from \\"custinf\\""
; 工作正常 我在使用mysql db時沒有遇到這個問題。 有人可以解釋嗎?
引用另一個問題的答案 :
select * from table3
數據庫將自動處理該數據庫,就像
select * from TABLE3
而
select * from "table3"
將成功匹配作為
create table "table3"
因此,如果您將表創建為custinf
,則必須使用"custinf"
。 使用不帶引號的 custinf
會將您的查詢轉換為使用可能不存在的表名CUSTINF
。
Derby表名稱區分大小寫。 它可能是“ Custinf”或“ custinf”。
您可以刪除custinf表並以適當的大小寫重新創建。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.