在postgres下将PreparedStatement参数设置为null的正确方法
||
即时通讯使用JDBC4(通过JDK6)使用最新的JDBC4驱动程序连接到PostgreSQL 9.0。
conn = dpaDs.getConnection();
PreparedStatement stmt = conn.prepareStatement(\"delete from fss where f_id=? and f_lastmodified=?\");
UUID target = UUID.fromString(\"8c5c5ac2-3a2a-49f3-ae48-29226d6ea3e7\");
stmt.setObject(1, target, 1111);
//non of these work
//stmt.setNull(2,93);
//stmt.setObject(2,null, 93);
//stmt.setObject(2,null, java.sql.Types.NULL);
//stmt.setNull(2, java.sql.Types.NULL);
int rowCount = stmt.executeUpdate();
int g = 8;
将2nd参数设置为null的正确方法是什么?
我知道我可以使用\“ where ... f_lastmodified为null \”,但是没有办法解决这个问题吗?
没有找到相关结果
已邀请:
2 个回复
犀寺扦
运算符进行NULL比较。如果要测试NULL,则必须使用
。 对于IS NULL条件,不能在准备好的语句中使用参数。
娠频摩
这有点尴尬,但是可以完成工作。我没有用jdbc尝试过,只有.net上的Npgsql尝试过,但是我认为应该是一样的。