Modified settings class

This commit is contained in:
anthorob committed 2021-09-21 11:39:21 -04:00
1 parent da82ed9491
commit 8f5c6b8cd5
6 files changed
+24 -13

No files matched your search

@@ -33,7 +33,7 @@ public class MysqlConnector {
dataSource.setPort(3306);
dataSource.setDatabaseName(dbName);
dataSource.setAutoReconnect(true);
dataSource.setAutoReconnectForPools(true);
dataSource.setConnectTimeout(5000);
c = dataSource.getConnection();
return this;
@@ -42,9 +42,9 @@ public class MysqlDatabase {
protected MysqlDatabase(String dbName) {
this.dbName = dbName;
String dbUser = Settings.getInstance().get("mysql.user");
String dbPass = Settings.getInstance().get("mysql.password");
String dbHost = Settings.getInstance().get("mysql.host");
String dbUser = Settings.getInstance().get("mysql.user", "root");
String dbPass = Settings.getInstance().get("mysql.password", "");
String dbHost = Settings.getInstance().get("mysql.host", "localhost");
try {
logger.info(String.format("Connecting to database '%1$s' at %2$s:3306", dbName, dbHost));
@@ -14,12 +14,14 @@ public class Settings {
private final Properties prop = new Properties();
public Settings() {
String configFile = "bot.config";
File file = new File("bot.config");
try {
InputStream is = Settings.class.getClassLoader().getResourceAsStream(configFile);
prop.load(is);
is.close();
file.createNewFile();
FileInputStream fis = new FileInputStream(file);
prop.load(fis);
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
-5
View File
@@ -1,5 +0,0 @@
bot.token=
bot.prefix=$
bot.owner=
bot.ownerguild=
bot.errorchannel=