• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Code to hit DB every 1 minute?

 
Amruta Jegarkal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know how can i write a code in java to check DB update every 1 minute?
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use a Timer and TimerTask. The TimerTask would be the code required to check the DB just once. Then you would schedule the TimerTask in a Timer to run 1/minute.
 
Amruta Jegarkal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is there any use of ScheduledExecutorService class in this?
 
Winston Gutkowski
Bartender
Pie
Posts: 10268
60
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amruta Jegarkal wrote:I want to know how can i write a code in java to check DB update every 1 minute?

Why?

It seems to me that you've leapt to an implementation without describing the problem. Back up and tell us what you're trying to do, and maybe we could give you better advice. What I can tell you is that "busy checking" is rarely the best solution.

Winston
 
Paul Clapham
Sheriff
Posts: 20980
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amruta Jegarkal wrote:
Is there any use of ScheduledExecutorService class in this?


Don't see why not. It should take you less than 10 minutes to try it out, shouldn't it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic