我似乎无法在准备好的语句中设置正确的类型。这段代码:
String sql = "delete from foo where ctid = ?";
PreparedStatement deleteStmt = conn.prepareStatement( sql );
deleteStmt.setString(1, "(0,43)"); // select ctid from foo shows (0,43) exists....
int a = deleteStmt.executeUpdate();
抛出此异常:
org.postgresql.util.PSQLException: ERROR: operator does not exist: tid = character varying
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts. Position: 28
请注意,从 psql 中,删除使用字符串进行:
mydb=# DELETE FROM foo where ctid = '(0,43)';
DELETE 1
JDBC PreparedStatement 中 tid 的正确类型/编码是什么?我试过 setRowId() (抛出 ava.sql.SQLFeatureNotSupportedException:方法 org.postgresql.jdbc4.Jdbc4PreparedStatement.setRowId(int, RowId) 尚未实现。)和 setBytes() (抛出 ...操作符不存在:tid =字节)