title: Tabe field status auto update checking system date using query in mysql & java
body: <p>table field status auto update when  checking with  system date and expirydate using query in mysql &amp; java</p>
  
  <p>In my table,</p>
  
  <p><em><strong>tbl-member:</em></strong></p>
  
  <p><em>id, name, expirydate,status</em>  are fields.</p>
  
  <p>How to use this with <strong>TRIGGER</strong></p>
  
  <p>(expirydate,systemdate)</p>
  
  <pre><code>CREATE
      TRIGGER autoupdation
  
      trigger_time UPDATE
  
      ON tbl-member FOR EACH ROW
  
      trigger_body
  </code></pre>
  
  <p><strong>how to create trigger_body for this function...</strong></p>
  
  <p>field expirydate check with system date and auto update the status field.</p>
  
  <p>here is the code use function for check-updation</p>
  
  <pre><code>@Override
      public List&lt;Member&gt; FindExpiredMembers() throws ParseException {
          List&lt;Member&gt; memberlistforreturn=new ArrayList&lt;&gt;();
          List&lt;Member&gt; memberlist=getAllMember();
          java.util.Date utilDate=new java.util.Date();
          java.sql.Date sqldate=new java.sql.Date(utilDate.getTime());
  
  
          for(Member i : memberlist){
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
          java.util.Date exp_Date=sdf.parse(sqldate.toString());
          java.util.Date renew_Date=sdf.parse(i.getRenewDate().toString());
              if(renew_Date.compareTo(exp_Date)&lt;0){
                  memberlistforreturn.add(i);
                  i.setStatus(true);
                  update(i);
              }
          }
          System.out.println(memberlistforreturn.size());
  
          System.out.println("working...!!!!!!");
          return memberlistforreturn;
      }
  </code></pre>
  
  <p>using this function the program run on slow</p>