Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes How can i run a particular  code for every 10 minutes 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 » Databases » JDBC
Bookmark "How can i run a particular  code for every 10 minutes" Watch "How can i run a particular  code for every 10 minutes" New topic
Author

How can i run a particular code for every 10 minutes

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi

I am trying to cache the data to reduce the hits to Daabase.

So for this i am storing the data in application scope .

Please tell me how can i for every 10 minutes clear my Application data and put new data into it.
How can i do this for every 10 minutes .

Thanks .


Save India From Corruption - Anna Hazare.
Praveen Rajendran
Greenhorn

Joined: Dec 25, 2009
Posts: 21
Hi Ravi,
I guess you can write your caching program in a servlet such that the cache function will be done in a while loop with always true condition. Also the timing interval of caching can be done by using Thread.sleep(time) method defining the interval time in milli seconds. The servlet can be configured to trigger on application startup using web.xml.
Let me know if this makes sense.


Thanks & Regards,
Praveen
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30085
    
149

Or you could let Java handle it for you. Look at the TimerTask and Timer classes.



[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you all . Its easy to go for Timer and TimerTask .
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

I prefer Java Quartz for scheduling solutions.


My Blog: Down Home Country Coding with Scott Selikoff
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30085
    
149

Scott,
For anything complex, I prefer Quartz as well. For scheduling one or two simple jobs - I go with TimerTask.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i run a particular code for every 10 minutes
 
Similar Threads
copy data from one table to another every 30 minutes through a stored procedure in oracle pl sql
Force session replication in Tomcat 5.5
Reading logs from Unix server
How to render a web page inside java?
How to capture the event that application is completed started in WebSpere 6.1 Server