public synchronized ArrayList<String> devicesToBeDeleted() {
        ArrayList<String> devicesToBeDeleted = new ArrayList<String>();
        ResultSet result = null;
        String sqlUpdateTable;
        double curtime = System.currentTimeMillis()/1000;
        try {
            connection = (Connection) DriverManager.getConnection(connectionUrl);
            statement = connection.createStatement();
            sqlUpdateTable = "SELECT * FROM devices;";
            result = statement.executeQuery(sqlUpdateTable);
            while (result.next()) {
                if (curtime - result.getDouble("time") > time/1000) {
                    devicesToBeDeleted.add(result.getString("device"));
                }
            }
        } catch (SQLException ex) {
            ex.getErrorCode();
        } finally {
            try { statement.close();
                connection.close();
            } catch (SQLException ex) { ex.printStackTrace(); }
        }  
        return devicesToBeDeleted;
    }