Radhika Kulkarni Radhika Kulkarni - 1 year ago 63
Java Question

delete database automatically after a particular date when date column is not available in database

I want to delete database after 31st march of any year. However i don't have date column in my database. Can u please tell the java code which will do this?
I have searched that i can probably use events in myql but i am not getting how to use it to suit my application. Also, is there any better option?
I have created following database:

CREATE TABLE `amount` (

`userName` VARCHAR(100),
`DayCareAmount` INT(11) DEFAULT NULL,
`HealthCareAmount` INT(11) DEFAULT NULL,
`HealthClubAmount` INT(11) DEFAULT NULL,

PRIMARY KEY (`userName`)

Answer Source

alter your table to add date or year field

ALTER TABLE table_name
ADD column_name datatype

update your amount fields with respect to the date I got the current financial year as follows

public int getyear( LocalDate date) {
        if(date.getMonthValue() < 4){
            return date.getYear() - 1;
        return date.getYear();

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download