Question: I am trying to delete a row in my table. Here is my sample code

```
String DBDate = new String();
Long date = new Date().getTime();           
String dateToday = date.toString();             
dbobj.clear();
dbobj.put(LAST_TIME_ANSWERED, "");
int hasDB = dbobj.getFromDB(tableName,column key, primary key);

if(hasDB != 0) {
    DBDate = dbobj.get(LAST_TIME_ANSWERED);
    if(DBDate != dateToday) {
        dbobj.deleteClientDB(tableName, column key, primary key);
    }
}

```

How could I change the date of a timer?
Any help would be nice. Thanks in advance!

Answer: 
This is awkward to achieve in java, because you need to run a job on a schedule to achieve this. You should strongly consider using the mysql event scheduler. See [this answer](https://stackoverflow.com/a/14806127/2051454) for an example of this.

When you insert the row in the db you should set up an event that is triggered exactly once, 24-hours later, with the necessary sql to delete the row. You would end up with one event per row.

Alternatively, with java and a properly configured server, after each row insert you could add a cron or quartz job that would trigger once, 24-hours later, that would invoke a java function to remove the row. This is harder than using the db's built-in event scheduler. 

Depending on your JEE version (>6) you could use an EJB 3.1 timer, as detailed in [this blog post](http://www.adam-bien.com/roller/abien/entry/simplest_possible_ejb_3_16). 

Of these options, the db event scheduler is probably the best, because the others can go wrong if the JEE sever is down.
there are two options for this.
1.) use java scheduler or
2.) use a scheduled job at DB level to clear data at the end of each day