我试过了这个查询
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时我没有遇到过这个问题。任何人都可以解释一下吗?
答案 0 :(得分:1)
引用an answer to a different question:
select * from table3
将由数据库自动处理,就像它是
一样select * from TABLE3
,而
select * from "table3"
将成功匹配您创建的表
create table "table3"
因此,如果您的表格已设为custinf
,则必须使用"custinf"
。使用不带引号的custinf
会将您的查询转换为使用可能不存在的表名CUSTINF
。
答案 1 :(得分:0)
Derby表名称区分大小写。它可能是" Custinf"或" custinf"。
您可以删除custinf表并使用适当的大小写重新创建。