Modified settings class
This commit is contained in:
1 parent
da82ed9491
commit
8f5c6b8cd5
6 files changed
+24
-13
No files matched your search
@@ -7,6 +7,9 @@
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Config file
|
||||
bot.config
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
bot.token=
|
||||
bot.prefix=
|
||||
bot.owner=
|
||||
bot.ownerguild=
|
||||
bot.errorchannel=
|
||||
|
||||
mysql.host=localhost
|
||||
mysql.user=root
|
||||
mysql.password=
|
||||
mysql.database=
|
||||
mysql.port=3306
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
bot.token=
|
||||
bot.prefix=$
|
||||
bot.owner=
|
||||
bot.ownerguild=
|
||||
bot.errorchannel=
|
||||
Reference in new issue
Block a user