Return number of rows affected by SQL UPDATE statement in Java

后端 未结 7 1911
花落未央
花落未央 2020-12-30 20:26

I\'m using a MySQL database and accessing it through Java.

PreparedStatement prep1 = this.connection.prepareStatement(
        \"UPDATE user_table 
                


        
相关标签:
7条回答
  • 2020-12-30 20:57

    Statement.executeUpdate() or execute() followed by getUpdateCount() will return the number of rows matched, not updated, according to the JDBC spec. If you want the updated count, you can specify useAffectedRows=true as a non-standard URL option. More information is available here.

    0 讨论(0)
提交回复
热议问题