2015-06-06 66 views
0

我嘗試這個查詢查詢在德比嵌入式數據庫

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數據庫時沒有遇到這個問題。有人可以解釋嗎?

+0

*表或視圖'CUSTINF'是否存在? –

+0

存在其他明智的第二個查詢將無法正常工作「select * from」custinf「」 – Burusothman

+0

請參閱https://stackoverflow.com/questions/12203787/derby-database-table-column-name-format-inconsistent-in-詢問 –

回答

0

德比表名是區分大小寫的。它可能是「Custinf」或「custinf」。

您可以放下custinf表並重新創建適當的大小寫。

1

an answer to a different question引用:

select * from table3 

將通過數據庫進行自動處理,如果它是

select * from TABLE3 

select * from "table3" 

將成功匹配表,你創建爲create table "table3"

因此,如果您的表格被創建爲custinf您必須使用"custinf"。使用custinf不帶引號會將您的查詢轉換爲使用表名CUSTINF,這可能不存在。