我正在尝试使用jdbc运行查询,但是我很难将值注入到准备好的语句中。这是我正在做的事情的一个示例:
String queryString = "... WHERE location <@ box '((?,?),(?,?))' ..."
PreparedStatement ps = this.connection.prepareStatement(queryString);
ps.setDouble(1,x1);
ps.setDouble(2,y1);
ps.setDouble(3,x2);
ps.setDouble(4,y2);
ps.executeUpdate();
哪个给我这个错误:
org.postgresql.util.PSQLException: The column index is out of range: 1,number of columns: 0.
我认为它认为单引号中的值是字符串文字,因此看不到?作为要注入的参数。
有人知道我该如何解决吗?还是我还应该做什么?