且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误:列不存在

更新时间:2022-05-23 17:40:15

当涉及到 Postgresql 和实体名称(Tables、Columns 等)的大写字母时,需要将单词转义"到".请参阅文档 关于这个特定主题.所以,你的例子会写成这样:

When it comes to Postgresql and entity names (Tables, Columns, etc.) with UPPER CASE letters, you need to "escape" the word by placing it in "". Please refer to the documentation on this particular subject. So, your example would be written like this:

String stm = "DELETE FROM hostdetails WHERE "MAC" = 'kzhdf'";

附带说明,考虑到您使用的是准备好的语句,您不应该直接在 SQL 语句中设置值.

On a side note, considering you are using prepared statements, you should not be setting the value directly in your SQL statement.

con = DriverManager.getConnection(url, user, password);
String stm = "DELETE FROM hostdetails WHERE "MAC" = ?";
pst = con.prepareStatement(stm);
pst.setString(1, "kzhdf");
pst.executeUpdate();