0

I tried this query

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);
        }

It throws

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

When i change the query to String sql1="select * from \"custinf\""; It's working. I haven't faced this problem while using mysql db. can anybody explain it?

3
  • Does the table or view CUSTINF exist? Commented Jun 6, 2015 at 4:55
  • exist other wise second query won't work "select * from \"custinf\"" Commented Jun 6, 2015 at 4:56
  • See stackoverflow.com/questions/12203787/… Commented Jun 6, 2015 at 5:14

2 Answers 2

1

To quote from an answer to a different question:

select * from table3

will be automatically processed by the database as if it was

select * from TABLE3

while

select * from "table3"

will successfully match the table you created as create table "table3"

So if your table was created as custinf you must use "custinf". Using custinf without quotes will convert your query to use the table name CUSTINF which probably does not exist.

Sign up to request clarification or add additional context in comments.

Comments

0

Derby table names are case sensitive. It may be "Custinf" or "custinf".

You may drop custinf table and recreate with proper case.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.