0
I have a program here at the factory that, every 1 minute, an equipment connected to a supervisory launches a direct value in a table in the database (SQL Server).
I wonder how do I always take the last value and show in a JTextField
, and every minute he tries to make that query.
In case, this code suits me perfectly, but my doubt now how do I get the last database value that in the case would be (SQL Server).
int delay = 5000; // delay de 5 seg.
int interval = 5000; // intervalo de 1 seg.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
jTextField6.setText("1");
}
}, delay, interval);
}
Yes, it’s possible. What you’ve done?
– user28595
@Articuno, So far I have only made the change of these values, so that the person can set the values of an equipment from inside the office, but in order to stay loyal, I needed to bring this value real pq the equipment even setando, it never reaches the ideal temperature, because he always has the variation.
– Lucas16
In the case of java-swing, there is the class
swing.Timer
which will probably be the one you need to use. At this link teaches how it works and how to use, if you present something you’ve done in the format of a [mcve], I can demonstrate its use in practice.– user28595
At the moment I don’t have much to present to you, it’s more of a doubt and how can I start.
– Lucas16
Yes, the problem is that the doubt becomes broad in the way the question is, because beyond the way I explained it, there are countless others that cannot be explained here. If you present something to exemplify what you intended in a [mcve], it is easier to suggest something more specific.
– user28595
Blz, I’ll see what I can do with Timer, and if I have any doubts I’ll come to you.
– Lucas16
This is not the timer class you should use. It is the one I left the link, because it is a graphical interface.
– user28595
But in that case if I put a task for him to go in the bank and get the last information would work too, wouldn’t? or could give future problems?
– Lucas16