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 Murach's Java Servlets and JSP this week in the Servlets 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: 4165
    
  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: 7526
    
  18

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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    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?
 
Don't get me started about those stupid light bulbs.
 
subject: Code to hit DB every 1 minute?
 
Similar Threads
Implementing RESTful Grails services
Interesting Groovy Problem - Request for Help
Datasource url database name not known until after a Batch step
Loading Into Random Table
text file extractor