aspose 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
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: 3948
    
  17

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: 7058
    
  16

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?
Artlicles by Winston can be found here
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Code to hit DB every 1 minute?
 
Similar Threads
Loading Into Random Table
Interesting Groovy Problem - Request for Help
text file extractor
Implementing RESTful Grails services
Datasource url database name not known until after a Batch step