executeUpdate 返回行数而不是受影响的行
executeUpdate returning number of rows rather than affected rows
PreparedStatement updatestmt1 = con.prepareStatement("update BASE_TX set tx_vl=replace(tx_vl,?,?)");
updatestmt1.setString( 1, "${parm:"+ stringToreplace.trim() +"}" );
updatestmt1.setString( 2, "${parm:" + replacedString.trim() + "}" );
int ifUpdated1 = updatestmt1.executeUpdate();
ifUpdated1 返回 14480 而不是受影响的行数 none 在 im 运行 的情况下。因此,无论它们是否实际更新,我都无法拨打电话。
这是正确的行为。由于您没有设置 WHERE
,所有行都会受到影响。您的替换是身份这一事实与数据库无关。如果您真的想获得受影响的行,请像这样使用 where
:
"update BASE_TX set tx_vl=replace(tx_vl,?,?) where tx_vl != replace(tx_vl,?,?)"
请注意,它会减慢您的查询速度,但会减少 IO,这实际上对您的情况可能更好。
PreparedStatement updatestmt1 = con.prepareStatement("update BASE_TX set tx_vl=replace(tx_vl,?,?)");
updatestmt1.setString( 1, "${parm:"+ stringToreplace.trim() +"}" );
updatestmt1.setString( 2, "${parm:" + replacedString.trim() + "}" );
int ifUpdated1 = updatestmt1.executeUpdate();
ifUpdated1 返回 14480 而不是受影响的行数 none 在 im 运行 的情况下。因此,无论它们是否实际更新,我都无法拨打电话。
这是正确的行为。由于您没有设置 WHERE
,所有行都会受到影响。您的替换是身份这一事实与数据库无关。如果您真的想获得受影响的行,请像这样使用 where
:
"update BASE_TX set tx_vl=replace(tx_vl,?,?) where tx_vl != replace(tx_vl,?,?)"
请注意,它会减慢您的查询速度,但会减少 IO,这实际上对您的情况可能更好。