Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ActionListener task = new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent e) {
- String sql = "SELECT SensorID, luchtkwaliteit, tijdstip FROM tbl1 ORDER BY tijdstip DESC LIMIT 1";
- System.out.println("Updating sql");
- try {
- Connection conn = getConnection();
- Statement statement = conn.createStatement();
- ResultSet rs = statement.executeQuery(sql);
- if(rs.next()){
- tijdVar.setText(rs.getString("tijdstip").substring(11));
- luchtVariable = rs.getInt("luchtkwaliteit");
- sensorVariable = rs.getString("SensorID");
- }
- } catch (SQLException ex) {
- Logger.getLogger(dashboard.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- };
- Timer timer = new Timer(10000, task);
- timer.setRepeats(true);
- timer.start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement