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
|
# BlueJ files
|
||||||
*.ctxt
|
*.ctxt
|
||||||
|
|
||||||
|
# Config file
|
||||||
|
bot.config
|
||||||
|
|
||||||
# Mobile Tools for Java (J2ME)
|
# Mobile Tools for Java (J2ME)
|
||||||
.mtj.tmp/
|
.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.setPort(3306);
|
||||||
dataSource.setDatabaseName(dbName);
|
dataSource.setDatabaseName(dbName);
|
||||||
dataSource.setAutoReconnect(true);
|
dataSource.setAutoReconnect(true);
|
||||||
dataSource.setAutoReconnectForPools(true);
|
dataSource.setConnectTimeout(5000);
|
||||||
c = dataSource.getConnection();
|
c = dataSource.getConnection();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ public class MysqlDatabase {
|
|||||||
|
|
||||||
protected MysqlDatabase(String dbName) {
|
protected MysqlDatabase(String dbName) {
|
||||||
this.dbName = dbName;
|
this.dbName = dbName;
|
||||||
String dbUser = Settings.getInstance().get("mysql.user");
|
String dbUser = Settings.getInstance().get("mysql.user", "root");
|
||||||
String dbPass = Settings.getInstance().get("mysql.password");
|
String dbPass = Settings.getInstance().get("mysql.password", "");
|
||||||
String dbHost = Settings.getInstance().get("mysql.host");
|
String dbHost = Settings.getInstance().get("mysql.host", "localhost");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info(String.format("Connecting to database '%1$s' at %2$s:3306", dbName, dbHost));
|
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();
|
private final Properties prop = new Properties();
|
||||||
|
|
||||||
public Settings() {
|
public Settings() {
|
||||||
String configFile = "bot.config";
|
File file = new File("bot.config");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InputStream is = Settings.class.getClassLoader().getResourceAsStream(configFile);
|
file.createNewFile();
|
||||||
prop.load(is);
|
|
||||||
is.close();
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
prop.load(fis);
|
||||||
|
fis.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
bot.token=
|
|
||||||
bot.prefix=$
|
|
||||||
bot.owner=
|
|
||||||
bot.ownerguild=
|
|
||||||
bot.errorchannel=
|
|
||||||
Reference in new issue
Block a user