diff --git a/ArtificialAutism/src/main/java/DataLayer/DBCPDataSource.java b/ArtificialAutism/src/main/java/DataLayer/DBCPDataSource.java index de8486a2..7f87e1db 100644 --- a/ArtificialAutism/src/main/java/DataLayer/DBCPDataSource.java +++ b/ArtificialAutism/src/main/java/DataLayer/DBCPDataSource.java @@ -5,8 +5,12 @@ */ package DataLayer; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; +import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; @@ -21,10 +25,17 @@ public class DBCPDataSource { static { try { + Properties prop = new Properties(); + String fileName = "app.config"; + try (FileInputStream fis = new FileInputStream(fileName)) { + prop.load(fis); + } catch (FileNotFoundException ex) { + } catch (IOException ex) { + } ds.setDriver(new com.mysql.cj.jdbc.Driver()); - ds.setUrl(settings.url); - ds.setUsername(settings.username); - ds.setPassword(settings.password); + ds.setUrl(prop.getProperty("app.url")); + ds.setUsername(prop.getProperty("app.username")); + ds.setPassword(prop.getProperty("app.password")); ds.setMaxTotal(-1); ds.setMinIdle(5); ds.setMaxIdle(-1); diff --git a/ArtificialAutism/src/main/java/DataLayer/ThreadClient.java b/ArtificialAutism/src/main/java/DataLayer/ThreadClient.java index ef85244c..a5888ffb 100644 --- a/ArtificialAutism/src/main/java/DataLayer/ThreadClient.java +++ b/ArtificialAutism/src/main/java/DataLayer/ThreadClient.java @@ -3,15 +3,27 @@ package DataLayer; import FunctionLayer.Datahandler; import edu.stanford.nlp.pipeline.StanfordCoreNLP; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.*; +import java.util.Properties; public class ThreadClient { public ThreadClient(int port, Datahandler datahandler, StanfordCoreNLP stanfordCoreNLP, StanfordCoreNLP stanfordCoreNLPSentiment) { - String hostIP = new settings().getHostIP(); - if (port == new settings().getHostport() || port == new settings().getHostport2()) { - hostIP = new settings().getHostIP2(); + Properties prop = new Properties(); + String fileName = "app.config"; + try (FileInputStream fis = new FileInputStream(fileName)) { + prop.load(fis); + } catch (FileNotFoundException ex) { + } catch (IOException ex) { + } + + String hostIP = prop.getProperty("app.hostip"); + if (port == Integer.valueOf(prop.getProperty("app.hostport")) + || port == Integer.valueOf(prop.getProperty("app.hostport2"))) { + hostIP = prop.getProperty("app.hostip2"); } try { InetAddress ipAddress = InetAddress.getByName(hostIP);//used ip's diff --git a/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java b/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java index 0ed7adf3..51b838e1 100644 --- a/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java +++ b/ArtificialAutism/src/main/java/PresentationLayer/DiscordHandler.java @@ -17,12 +17,15 @@ import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.requests.GatewayIntent; import javax.security.auth.login.LoginException; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.*; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.Properties; import java.util.concurrent.Executors; @@ -46,7 +49,14 @@ public class DiscordHandler extends ListenerAdapter { System.out.println("FINISHED ALL ANNOTATIONS"); String strF = datahandler.trimString("abcdef"); datahandler.getResponseFutures(strF, stanfordCoreNLP, stanfordCoreNLPSentiment); - String token = new settings().getDiscordToken(); + Properties prop = new Properties(); + String fileName = "app.config"; + try (FileInputStream fis = new FileInputStream(fileName)) { + prop.load(fis); + } catch (FileNotFoundException ex) { + } catch (IOException ex) { + } + String token = prop.getProperty("app.discordtoken"); try { JDABuilder.createLight(token, GatewayIntent.GUILD_MESSAGES, GatewayIntent.DIRECT_MESSAGES)