更新操作,返回受影响的行数 @param connection @param pstm @param sql @param params @return @throws Exception
(Connection connection, PreparedStatement pstm,
String sql, Object[] params)
| 90 | * @throws Exception |
| 91 | */ |
| 92 | public static int executeUpdate(Connection connection, PreparedStatement pstm, |
| 93 | String sql, Object[] params) throws Exception { |
| 94 | int updateRows = 0; |
| 95 | pstm = connection.prepareStatement(sql); |
| 96 | for (int i = 0; i < params.length; i++) { |
| 97 | pstm.setObject(i + 1, params[i]); |
| 98 | } |
| 99 | updateRows = pstm.executeUpdate(); |
| 100 | return updateRows; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * |