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