File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Code to hit DB every 1 minute? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Code to hit DB every 1 minute?" Watch "Code to hit DB every 1 minute?" New topic
Author

Code to hit DB every 1 minute?

Amruta Jegarkal
Greenhorn

Joined: Nov 29, 2012
Posts: 29
I want to know how can i write a code in java to check DB update every 1 minute?
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

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.


Steve
Amruta Jegarkal
Greenhorn

Joined: Nov 29, 2012
Posts: 29

Is there any use of ScheduledExecutorService class in this?
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8661
    
  23

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19693
    
  10

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?
 
wood burning stoves
 
subject: Code to hit DB every 1 minute?
 
It's not a secret anymore!