70 lines
1.7 KiB
Java
Raw Normal View History

2019-10-04 16:52:14 +02:00
package com.wasteinformationserver.mqtt;
import com.wasteinformationserver.db.jdcb;
2019-10-11 09:03:14 +02:00
import javax.swing.table.DefaultTableModel;
2019-10-04 16:52:14 +02:00
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
2019-10-11 09:03:14 +02:00
import java.sql.Connection;
import java.sql.PreparedStatement;
2019-10-04 16:52:14 +02:00
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
public class mqtt {
2019-10-11 09:03:14 +02:00
private ArrayList<String> mylist = new ArrayList<>();
private int index = 0;
2019-10-04 16:52:14 +02:00
2019-10-11 09:03:14 +02:00
public mqtt() {
2019-10-04 16:52:14 +02:00
}
2019-10-11 09:03:14 +02:00
public void notifymessage() {
2019-10-04 16:52:14 +02:00
2019-10-11 09:03:14 +02:00
mqttreceiver mr = new mqttreceiver();
2019-10-04 16:52:14 +02:00
mr.addMessageReceivedListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
}
});
}
2019-10-11 09:03:14 +02:00
public void getDatabasedata() {
int n=0;
jdcb Database = new jdcb("placeuser", "eaL956R6yFItQVBl", "wasteinformation");
ResultSet result = Database.executeQuery("SELECT*FROM place WHERE Zone=1");
try {
while (result.next()) {
String temp = String.valueOf(result.getString("Abholtag"));
System.out.println(temp);
filllist(temp);
n++;
}
} catch (SQLException e) {
e.printStackTrace();
2019-10-04 16:52:14 +02:00
}
2019-10-11 09:03:14 +02:00
transmitmessagetoESP();
}
2019-10-04 16:52:14 +02:00
2019-10-11 09:03:14 +02:00
private void transmitmessagetoESP() {
mqtttransmitter mt = new mqtttransmitter(mylist);
2019-10-04 16:52:14 +02:00
}
2019-10-11 09:03:14 +02:00
private void filllist(String temp) {
mylist.add(index, temp);
2019-10-04 16:52:14 +02:00
}
2019-10-11 09:03:14 +02:00
public void printlist() {
for (int n = 0; n < index; n++) {
System.out.println(mylist.get(index));
}
2019-10-04 16:52:14 +02:00
}
}