There are task scheduling frameworks, however to just run a daily script you can use much simpler solutions. The operating systems have a task scheduler: in linux has the cron
, in windows has the Agendador de Tarefas
(less creative name, by the way).
Basically you create a program in java that when running sends the emails with the queries, without worrying about the time. To schedule, you create a script like this:
@echo off
REM run the program
"C:\Program Files\Java\jdk1.7.0\bin\java.exe" -jar "C:\Users\User1 \Documents\project\emailConsulta.jar"
Then, just create a task in the Windows Task Scheduler, accessed with Win+R > type "Taskschd.Msc" > Enter. There you control on which days of the week it will run, at what time, among other options.
Your question is to check or to schedule the execution of a code? In the first case, you need to know your data model. In the second, varies operating system, you need to inform.
– rodorgas
I want to schedule the execution of query check. Midnight run a method that checks for queries that day.
– Guilherme Nass
So which operating system??
– rodorgas
It is Windows :D
– Guilherme Nass
There are two ways of scheduling, "Jobs", in java applications, there is a post in this link that will surely guide you.
– rafaeldcfarias
Another option would be to use the EJB to make the scheduling in the java itself, in the same method you could do the checking you wanted. http://blog.caelum.com.br/agendando-tarefas-com-o-timerservice-do-ejb-3-1/
– Aleixo Porpino Filho