Java SQL “ERROR: Relation ”Table_Name“ does not exist”

前端 未结 4 1828
梦毁少年i
梦毁少年i 2020-12-07 02:39

I\'m trying to connect netbeans to my postgresql database. The connection seems to have worked as I don\'t get any errors or exceptions when just connecting, methods such as

4条回答
  •  生来不讨喜
    2020-12-07 03:33

    I suspect you created the table using double quotes using e.g. "Clients" or some other combination of upper/lowercase characters and therefor the table name is case sensitive now.

    What does the statement

     SELECT table_schema, table_name
     FROM information_schema.tables 
     WHERE lower(table_name) = 'clients'
    

    return?

    If the table name that is returned is not lowercase you have to use double quotes when referring to it, something like this:

    String query = "SELECT * FROM \"Clients\"";
    

提交回复
热议问题