jdbc - java database mismatch and error handling -


need return

"timestamp not match id: "+ id

if timestamp match or not in database below code. standard practice that?

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     } } 


Comments