changed folder structure
This commit is contained in:
parent
889cdef86b
commit
4e4ecb5dc6
@ -1,3 +1,3 @@
|
|||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Main-Class: main
|
Main-Class: com.wasteinformationserver.main
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
package com.wasteinformationserver;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
@ -1,10 +1,9 @@
|
|||||||
package website;
|
package com.wasteinformationserver.basicutils;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.logging.*;
|
|
||||||
|
|
||||||
public class Log {
|
public class Log {
|
||||||
|
|
||||||
@ -79,7 +78,7 @@ public class Log {
|
|||||||
builder.append("]");
|
builder.append("]");
|
||||||
|
|
||||||
builder.append(" [");
|
builder.append(" [");
|
||||||
builder.append(new Exception().getStackTrace()[1].getClassName());
|
builder.append(new Exception().getStackTrace()[2].getClassName());
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
|
|
||||||
builder.append(" [");
|
builder.append(" [");
|
@ -1,4 +1,4 @@
|
|||||||
package db;
|
package com.wasteinformationserver.db;
|
||||||
|
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -25,7 +25,7 @@ public abstract class Database {
|
|||||||
this.dbName = dbName;
|
this.dbName = dbName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Connection getConnection();
|
public abstract Connection getConnection() throws SQLException;
|
||||||
|
|
||||||
public static void logToConsole(ResultSet res) {
|
public static void logToConsole(ResultSet res) {
|
||||||
try {
|
try {
|
@ -1,4 +1,4 @@
|
|||||||
package db;
|
package com.wasteinformationserver.db;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
@ -18,20 +18,11 @@ public class MySQLConnector extends Database {
|
|||||||
super(user, password, host, port, dbName);
|
super(user, password, host, port, dbName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Connection getConnection() {
|
public Connection getConnection() throws SQLException {
|
||||||
Connection con = null;
|
return DriverManager.getConnection(
|
||||||
|
|
||||||
try {
|
|
||||||
con = DriverManager.getConnection(
|
|
||||||
"jdbc:mysql://" + host + ":" + port + "/" + dbName + "?useSSL=false",
|
"jdbc:mysql://" + host + ":" + port + "/" + dbName + "?useSSL=false",
|
||||||
user,
|
user,
|
||||||
password);
|
password);
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
System.err.println("no connection to database! start database server");
|
|
||||||
}
|
|
||||||
|
|
||||||
return con;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package website;
|
package com.wasteinformationserver.db;
|
||||||
|
|
||||||
import com.sun.net.httpserver.Headers;
|
import com.sun.net.httpserver.Headers;
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpExchange;
|
@ -1,4 +1,4 @@
|
|||||||
package db;
|
package com.wasteinformationserver.db;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
@ -1,4 +1,8 @@
|
|||||||
package db;
|
package com.wasteinformationserver.db;
|
||||||
|
|
||||||
|
import com.wasteinformationserver.basicutils.Log;
|
||||||
|
import com.wasteinformationserver.db.Database;
|
||||||
|
import com.wasteinformationserver.db.MySQLConnector;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@ -16,7 +20,11 @@ Connection conn;
|
|||||||
3306,
|
3306,
|
||||||
dbName);
|
dbName);
|
||||||
|
|
||||||
conn = db.getConnection();
|
try {
|
||||||
|
conn = db.getConnection();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Log.error("no connection to Database! DB Server not started...?");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,12 @@
|
|||||||
import db.jdcb;
|
package com.wasteinformationserver;
|
||||||
import website.Log;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import com.wasteinformationserver.basicutils.Log;
|
||||||
import java.sql.ResultSet;
|
import com.wasteinformationserver.website.Webserver;
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class main {
|
public class main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
/*
|
/*
|
||||||
Date D=new Date();
|
com.wasteinformationserver.Date D=new com.wasteinformationserver.Date();
|
||||||
D.getdata();
|
D.getdata();
|
||||||
D.printList();
|
D.printList();
|
||||||
*/
|
*/
|
||||||
@ -24,7 +22,7 @@ public class main {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Thread mythread = new Thread(() -> new website.Webserver().startserver());
|
Thread mythread = new Thread(() -> new Webserver().startserver());
|
||||||
mythread.start();
|
mythread.start();
|
||||||
|
|
||||||
Log.message("thread started");
|
Log.message("thread started");
|
@ -1,3 +1,5 @@
|
|||||||
|
package com.wasteinformationserver;
|
||||||
|
|
||||||
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;
|
||||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
import org.eclipse.paho.client.mqttv3.MqttException;
|
@ -1,4 +1,6 @@
|
|||||||
package website;
|
package com.wasteinformationserver.website;
|
||||||
|
|
||||||
|
import com.wasteinformationserver.db.PostRequest;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package website;
|
package com.wasteinformationserver.website;
|
||||||
|
|
||||||
import com.sun.net.httpserver.Headers;
|
import com.sun.net.httpserver.Headers;
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
@ -6,9 +6,6 @@ import com.sun.net.httpserver.HttpHandler;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public abstract class GetRequest implements HttpHandler {
|
public abstract class GetRequest implements HttpHandler {
|
||||||
@ -41,8 +38,8 @@ public abstract class GetRequest implements HttpHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param params received get params from website
|
* @param params received get params from com.wasteinformationserver.website
|
||||||
* @return json reply to website
|
* @return json reply to com.wasteinformationserver.website
|
||||||
*/
|
*/
|
||||||
public abstract String myrequest(HashMap<String, String> params);
|
public abstract String myrequest(HashMap<String, String> params);
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package website;
|
package com.wasteinformationserver.website;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
@ -1,6 +1,7 @@
|
|||||||
package website;
|
package com.wasteinformationserver.website;
|
||||||
|
|
||||||
import db.jdcb;
|
import com.wasteinformationserver.db.PostRequest;
|
||||||
|
import com.wasteinformationserver.db.jdcb;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
@ -1,4 +1,4 @@
|
|||||||
package website;
|
package com.wasteinformationserver.website;
|
||||||
|
|
||||||
public class LoginState {
|
public class LoginState {
|
||||||
private LoginState() {}
|
private LoginState() {}
|
@ -1,8 +1,9 @@
|
|||||||
package website;
|
package com.wasteinformationserver.website;
|
||||||
|
|
||||||
import com.sun.net.httpserver.Headers;
|
import com.sun.net.httpserver.Headers;
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
import com.sun.net.httpserver.HttpHandler;
|
import com.sun.net.httpserver.HttpHandler;
|
||||||
|
import com.wasteinformationserver.basicutils.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
@ -1,10 +1,11 @@
|
|||||||
package website;
|
package com.wasteinformationserver.website;
|
||||||
|
|
||||||
import db.jdcb;
|
import com.wasteinformationserver.db.PostRequest;
|
||||||
|
import com.wasteinformationserver.db.jdcb;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class RegisterRequest extends PostRequest{
|
public class RegisterRequest extends PostRequest {
|
||||||
@Override
|
@Override
|
||||||
public String request(HashMap<String, String> params) {
|
public String request(HashMap<String, String> params) {
|
||||||
System.out.println(params.toString());
|
System.out.println(params.toString());
|
@ -1,11 +1,11 @@
|
|||||||
package website;
|
package com.wasteinformationserver.website;
|
||||||
|
|
||||||
import com.sun.net.httpserver.HttpServer;
|
import com.sun.net.httpserver.HttpServer;
|
||||||
|
import com.wasteinformationserver.basicutils.Log;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
|
|
||||||
public class Webserver {
|
public class Webserver {
|
Loading…
Reference in New Issue
Block a user