• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to develop a java file that can delete 3 months old record of a table  RSS feed

 
Sumit RawalArora
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We take a table as input and we need to set the timing in such a way it will delete all the records of the input table which are older than 3 months
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need to write an SQL query for that and execute that query using JDBC.
 
Sumit RawalArora
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here I need to work using Spring JDBC template. I have an input table whose records are being updated on a regular basis.
My task is to develop a java file that will automatically detect records which are more than 3 months 90 days old and delete those records from database automatically when time comes
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to write the SQL query first and then see how to execute that query using Spring JDBC.
Then it can be scheduled in Java to run at regular interval.

Java alone cannot detect whether records in DB are 3 months old.
 
Sumit RawalArora
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have already written SQL query. Query part is done. Now I have to work on Java only. I need to execute query using Spring JDBCTemplate and DataSource. Please ask if you have any other question. I can give you as much details as you need to reply to my question
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good, now when the query part is done, it is time to execute the query.
Have you gone through Spring jdbctemplate tutorials to check how to execute query?
Have you tried something yet?
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, you have two steps left now.
The first (as Tapas suggests) is to write the Spring code.
The second is to sort out a way of scheduling it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!