hfhgf
This commit is contained in:
parent
54aa35563b
commit
6b8cb9cc10
0
JavaSample-tcp19216865151883/.lck
Normal file
0
JavaSample-tcp19216865151883/.lck
Normal file
0
UniquedeviceID-tcp19216864151883/.lck
Normal file
0
UniquedeviceID-tcp19216864151883/.lck
Normal file
0
UniquedeviceID-tcp19216865151883/.lck
Normal file
0
UniquedeviceID-tcp19216865151883/.lck
Normal file
@ -9,5 +9,7 @@
|
|||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="org.eclipse.paho.client.mqttv3-1.2.1" level="project" />
|
<orderEntry type="library" name="org.eclipse.paho.client.mqttv3-1.2.1" level="project" />
|
||||||
<orderEntry type="library" name="mysql-connector-java-5.1.44-bin" level="project" />
|
<orderEntry type="library" name="mysql-connector-java-5.1.44-bin" level="project" />
|
||||||
|
<orderEntry type="library" name="mysql-connector-java-5.1.44-bin" level="project" />
|
||||||
|
<orderEntry type="library" name="org.eclipse.paho.client.mqttv3-1.2.1" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -19,12 +19,12 @@ public class Date {
|
|||||||
public void getdata() {
|
public void getdata() {
|
||||||
|
|
||||||
GregorianCalendar now = new GregorianCalendar();
|
GregorianCalendar now = new GregorianCalendar();
|
||||||
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM); // 14.04.2012
|
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
|
||||||
String datum = df.format(now.getTime());
|
String datum = df.format(now.getTime());
|
||||||
|
|
||||||
URL url = null;
|
URL url = null;
|
||||||
try {
|
try {
|
||||||
url = new URL("https://www.steyr.at/system/web/kalender.aspx?vdatum=" + datum + "&bdatum=12.10.2019&typ=&typid=0&typids=225781950&detailonr=0&menuonr=225781812");
|
url = new URL("https://www.steyr.at/system/web/kalender.aspx?vdatum="+datum+"&bdatum=19.10.2019&typ=&typid=0&typids=225781950&detailonr=0&menuonr=225781812");
|
||||||
Scanner scanner = new Scanner(new InputStreamReader(url.openStream()));
|
Scanner scanner = new Scanner(new InputStreamReader(url.openStream()));
|
||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -46,6 +46,12 @@ public class Date {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void printList() {
|
public void printList() {
|
||||||
|
for (int n = 0; n < list.size(); n++) {
|
||||||
|
System.out.println(list.get(n));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void printListnew() {
|
||||||
for (int n = 0; n < listnew.size(); n++) {
|
for (int n = 0; n < listnew.size(); n++) {
|
||||||
System.out.println(listnew.get(n));
|
System.out.println(listnew.get(n));
|
||||||
}
|
}
|
||||||
@ -68,18 +74,30 @@ public class Date {
|
|||||||
zaehler++;
|
zaehler++;
|
||||||
}
|
}
|
||||||
|
|
||||||
String string = "004-034556";
|
/* String string = "004-034556";
|
||||||
String[] parts = string.split("-");
|
String[] parts = string.split("-");
|
||||||
String part1 = parts[0]; // 004
|
String part1 = parts[0]; // 004
|
||||||
String part2 = parts[1]; // 034556
|
String part2 = parts[1]; // 034556*/
|
||||||
|
|
||||||
for (int q = 0; q < listnew.size(); q++) {
|
splitter();
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void splitter()
|
||||||
|
{
|
||||||
|
String temp="</ul><h2>";
|
||||||
|
|
||||||
|
for (int n=0; n<listnew.size();n++)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(listnew.get(n).equals(temp))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@ import java.sql.ResultSetMetaData;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public abstract class Database {
|
public abstract class
|
||||||
|
Database {
|
||||||
|
|
||||||
protected String user;
|
protected String user;
|
||||||
protected String password;
|
protected String password;
|
||||||
|
@ -12,18 +12,18 @@ import java.sql.SQLException;
|
|||||||
public class jdcb {
|
public class jdcb {
|
||||||
Connection conn;
|
Connection conn;
|
||||||
|
|
||||||
public jdcb(String username, String password, String dbName) {
|
public jdcb(String username, String password,String dbname) {
|
||||||
Database db = new MySQLConnector(
|
Database db = new MySQLConnector(
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
"192.168.65.15",
|
"192.168.65.15",
|
||||||
3306,
|
3306,
|
||||||
dbName);
|
dbname);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
conn = db.getConnection();
|
conn = db.getConnection();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.error("no connection to Database! DB Server not started...?");
|
Log.error("no connection to Database!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -32,7 +32,6 @@ Connection conn;
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement stmt = conn.prepareStatement(sql);
|
PreparedStatement stmt = conn.prepareStatement(sql);
|
||||||
|
|
||||||
return stmt.executeQuery();
|
return stmt.executeQuery();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package com.wasteinformationserver;
|
package com.wasteinformationserver;
|
||||||
|
|
||||||
import com.wasteinformationserver.basicutils.Log;
|
import com.wasteinformationserver.mqtt.*;
|
||||||
import com.wasteinformationserver.website.Webserver;
|
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||||
|
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class main {
|
public class main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -11,7 +14,7 @@ public class main {
|
|||||||
D.printList();
|
D.printList();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
/* Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
Log.warning("Shutting down ...");
|
Log.warning("Shutting down ...");
|
||||||
@ -25,9 +28,15 @@ public class main {
|
|||||||
Thread mythread = new Thread(() -> new Webserver().startserver());
|
Thread mythread = new Thread(() -> new Webserver().startserver());
|
||||||
mythread.start();
|
mythread.start();
|
||||||
|
|
||||||
Log.message("thread started");
|
Log.message("thread started");*/
|
||||||
|
|
||||||
|
|
||||||
|
mqtt m=new mqtt();
|
||||||
|
// m.notifymessage();
|
||||||
|
try {
|
||||||
|
m.getDatabasedata();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
src/com/wasteinformationserver/mqtt/Database.java
Normal file
4
src/com/wasteinformationserver/mqtt/Database.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package com.wasteinformationserver.mqtt;
|
||||||
|
|
||||||
|
public class Database {
|
||||||
|
}
|
58
src/com/wasteinformationserver/mqtt/mqtt.java
Normal file
58
src/com/wasteinformationserver/mqtt/mqtt.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package com.wasteinformationserver.mqtt;
|
||||||
|
|
||||||
|
import com.wasteinformationserver.db.jdcb;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class mqtt {
|
||||||
|
|
||||||
|
private ArrayList<String> mylist=new ArrayList<>();
|
||||||
|
private int index=0;
|
||||||
|
|
||||||
|
public mqtt(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void notifymessage(){
|
||||||
|
|
||||||
|
mqttreceiver mr=new mqttreceiver();
|
||||||
|
|
||||||
|
mr.addMessageReceivedListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
System.out.println(e.getActionCommand());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getDatabasedata() throws SQLException {
|
||||||
|
jdcb database=new jdcb("placeuser","eaL956R6yFItQVBl","wasteinformation");
|
||||||
|
ResultSet result = database.executeQuery("SELECT*FROM place");
|
||||||
|
|
||||||
|
while(result.next())
|
||||||
|
{
|
||||||
|
String temp= String.valueOf(result.getStatement());
|
||||||
|
filllist(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//transmitmessagetoESP();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void transmitmessagetoESP()
|
||||||
|
{
|
||||||
|
|
||||||
|
mqtttransmitter mt=new mqtttransmitter();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void filllist(String temp)
|
||||||
|
{
|
||||||
|
mylist.add(index,temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
59
src/com/wasteinformationserver/mqtt/mqttreceiver.java
Normal file
59
src/com/wasteinformationserver/mqtt/mqttreceiver.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package com.wasteinformationserver.mqtt;
|
||||||
|
|
||||||
|
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||||
|
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class mqttreceiver {
|
||||||
|
|
||||||
|
MqttClient client;
|
||||||
|
String message;
|
||||||
|
|
||||||
|
ArrayList<ActionListener> mylisteners = new ArrayList<>();
|
||||||
|
|
||||||
|
public mqttreceiver() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = new MqttClient("tcp://192.168.65.15:1883", "JavaSample");
|
||||||
|
client.connect();
|
||||||
|
|
||||||
|
client.setCallback(new MqttCallback() {
|
||||||
|
@Override
|
||||||
|
public void connectionLost(Throwable throwable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||||
|
System.out.println(new String(mqttMessage.getPayload()));
|
||||||
|
notifylisteners(new String(mqttMessage.getPayload()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
client.subscribe("test/topic");
|
||||||
|
} catch (MqttException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifylisteners(String message){
|
||||||
|
for (ActionListener ac:mylisteners) {
|
||||||
|
new ActionEvent(this,0,message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMessageReceivedListener(ActionListener l){
|
||||||
|
mylisteners.add(l);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.wasteinformationserver;
|
package com.wasteinformationserver.mqtt;
|
||||||
|
|
||||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||||
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
|
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
|
||||||
@ -6,12 +6,14 @@ import org.eclipse.paho.client.mqttv3.MqttException;
|
|||||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||||
|
|
||||||
public class mqtt {
|
public class mqtttransmitter {
|
||||||
public mqtt() {
|
|
||||||
String topic = "MQTT Examples";
|
public mqtttransmitter() {
|
||||||
|
|
||||||
|
String topic = "kk";
|
||||||
String content = "Message from MqttPublishSample";
|
String content = "Message from MqttPublishSample";
|
||||||
int qos = 2;
|
int qos = 2;
|
||||||
String broker = "tcp://iot.eclipse.org:1883";
|
String broker = "tcp://192.168.65.15:1883";
|
||||||
String clientId = "JavaSample";
|
String clientId = "JavaSample";
|
||||||
MemoryPersistence persistence = new MemoryPersistence();
|
MemoryPersistence persistence = new MemoryPersistence();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user