Home >Database >Mysql Tutorial >Why Does My PostgreSQL DELETE Statement Throw a 'Column Does Not Exist' Error in Java?
PostgresSQL: "Error: Column does not exist" When Deleting Table Records
In Java, when attempting to delete records from a PostgreSQL table, an "Error: column does not exist" may be thrown. This error is often attributed to column names written in uppercase.
PostgresSQL is case-sensitive for its entity names (tables, columns, etc.). To address this issue, column names written in uppercase must be "escaped" using double quotes ("). For example, the following query will execute successfully:
String stm = "DELETE FROM hostdetails WHERE \"MAC\" = 'kzhdf'";
Additionally, using prepared statements, the value should not be directly set within the SQL statement. Instead, use the setString() method to pass the parameter value:
pst.setString(1, "kzhdf");
The above is the detailed content of Why Does My PostgreSQL DELETE Statement Throw a 'Column Does Not Exist' Error in Java?. For more information, please follow other related articles on the PHP Chinese website!