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,而不是受影响的行数,在im运行的情况下,这些行都不存在。因此,无论他们是否实际更新,我都无法拨打电话。
最佳答案
这是正确的行为。由于未设置WHERE
,因此所有行均会受到影响。您的替换是身份这一事实与数据库无关。如果您确实想获取受影响的行,请使用where
这样:"update BASE_TX set tx_vl=replace(tx_vl,?,?) where tx_vl != replace(tx_vl,?,?)"
请注意,这会降低查询速度,但会降低IO,实际上这可能会更好。
关于java - executeUpdate返回行数,而不是受影响的行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47031489/