需要返回
“时间戳与ID匹配:”+ id
如果时间戳匹配或未在数据库中匹配以下代码。 这是什么标准做法?
public void update(User entity) throws Exception {
try(Connection conn = DBConnection.getConnection()){
String sql = "UPDATE USERS SET " +
"FLAG = ?" +
"WHERE ID = ? " +
"AND LASTUPDATEDTIMESTAMP = ?";
PreparedStatement preparedStatement = conn.prepareStatement(sql);
preparedStatement.setBoolean(1, entity.getFlag());
preparedStatement.setString(2, entity.getId());
preparedStatement.setTimestamp(3, new java.sql.Timestamp(entity.getLastUpdatedTimestamp()));
int updateCount = preparedStatement.executeUpdate();
//logic here
}catch(SqlException e){
// method here
}
}