This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes TimerTask in Struts for handling Stored Procedures. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

TimerTask in Struts for handling Stored Procedures.

Thierry Collogne
Greenhorn

Joined: Oct 19, 2005
Posts: 16
Hi,

I am developing a web application. In the application I have developed a timertask that is responsible for checking a table every 2 minutes. If a record in the table matches a condition, a SQL Stored procedure is called for that record.

So far no problem. The problem comes in the fact that multiple records can match the condition and the Stored Procedure takes some time to complete.
So for each matching record the procedure will be run.

So when 2 minutes have passed and the timertask again checks the database, it is possible that more and more records match the condition.

How can I make sure that the stored procedure is run for every record?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Thierry,
Please do not cross post your questions.
You've already asked this in the Struts and Servlet forums.
http://www.coderanch.com/forums/


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

First off, please do not post the same question to multiple forums...

In answer to the question - unless the scheduled task that you're doing can be launched from your web application, or directly involves data in your web application that you can't get from the database, I'd suggest finding some other way of doing this than from a TimerTask inside your web application...

How can records get into the new "condition"? Why not update the records in response to this? (Of course, this may be beyond your control...)

Can your database schedule jobs? If so, I'd put the timing and job control there...

If you're stuck on controlling this from your web application, I'd then like to suggest using Quartz - it's pretty easy to get the hang of, and you won't have to muck around with threads and timer tasks directly...


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: TimerTask in Struts for handling Stored Procedures.