Return number of rows affected by SQL UPDATE statement in Java

后端 未结 7 1962
花落未央
花落未央 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:44

    That number is returned when you run the query:

    int rows = prep1.executeUpdate(); 
    System.out.printf("%d row(s) updated!", rows); 
    

提交回复
热议问题