Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. ActionListener task = new ActionListener(){
  2. @Override
  3. public void actionPerformed(ActionEvent e) {
  4. String sql = "SELECT SensorID, luchtkwaliteit, tijdstip FROM tbl1 ORDER BY tijdstip DESC LIMIT 1";
  5. System.out.println("Updating sql");
  6. try {
  7. Connection conn = getConnection();
  8. Statement statement = conn.createStatement();
  9. ResultSet rs = statement.executeQuery(sql);
  10. if(rs.next()){
  11. tijdVar.setText(rs.getString("tijdstip").substring(11));
  12. luchtVariable = rs.getInt("luchtkwaliteit");
  13. sensorVariable = rs.getString("SensorID");
  14. }
  15.  
  16. } catch (SQLException ex) {
  17. Logger.getLogger(dashboard.class.getName()).log(Level.SEVERE, null, ex);
  18. }
  19. }
  20. };
  21. Timer timer = new Timer(10000, task);
  22. timer.setRepeats(true);
  23. timer.start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement