Fix a fail returned from the database in the database thread

Rename some functions
This commit is contained in:
GeorgH93 2017-01-23 06:08:47 +01:00
parent 329ef26cb6
commit ba5eb84c61
3 changed files with 17 additions and 10 deletions

View File

@ -87,27 +87,27 @@ public String getDatabaseType()
return config.getString("Database.Type", "sqlite"); return config.getString("Database.Type", "sqlite");
} }
public String getMySQLHost() public String getSQLHost()
{ {
return config.getString("Database.SQL.Host", "localhost"); return config.getString("Database.SQL.Host", "localhost");
} }
public String getMySQLDatabase() public String getSQLDatabase()
{ {
return config.getString("Database.SQL.Database", "minecraft"); return config.getString("Database.SQL.Database", "minecraft");
} }
public String getMySQLUser() public String getSQLUser()
{ {
return config.getString("Database.SQL.User", "minecraft"); return config.getString("Database.SQL.User", "minecraft");
} }
public String getMySQLPassword() public String getSQLPassword()
{ {
return config.getString("Database.SQL.Password", ""); return config.getString("Database.SQL.Password", "");
} }
public int getMySQLMaxConnections() public int getSQLMaxConnections()
{ {
return config.getInt("Database.SQL.MaxConnections", 4); return config.getInt("Database.SQL.MaxConnections", 4);
} }

View File

@ -37,11 +37,11 @@ public MySQL(Minepacks mp)
protected HikariConfig getPoolConfig() protected HikariConfig getPoolConfig()
{ {
HikariConfig poolConfig = new HikariConfig(); HikariConfig poolConfig = new HikariConfig();
poolConfig.setJdbcUrl("jdbc:mysql://" + plugin.config.getMySQLHost() + "/" + plugin.config.getMySQLDatabase() + "?allowMultiQueries=true&autoReconnect=true"); poolConfig.setJdbcUrl("jdbc:mysql://" + plugin.config.getSQLHost() + "/" + plugin.config.getSQLDatabase() + "?allowMultiQueries=true&autoReconnect=true");
poolConfig.setUsername(plugin.config.getMySQLUser()); poolConfig.setUsername(plugin.config.getSQLUser());
poolConfig.setPassword(plugin.config.getMySQLPassword()); poolConfig.setPassword(plugin.config.getSQLPassword());
poolConfig.setMinimumIdle(1); poolConfig.setMinimumIdle(1);
poolConfig.setMaximumPoolSize(plugin.config.getMySQLMaxConnections()); poolConfig.setMaximumPoolSize(plugin.config.getSQLMaxConnections());
return poolConfig; return poolConfig;
} }

View File

@ -383,7 +383,14 @@ public void run()
catch(SQLException e) catch(SQLException e)
{ {
e.printStackTrace(); e.printStackTrace();
callback.onFail(); //TODO sync with main thread plugin.getServer().getScheduler().runTask(plugin, new Runnable()
{
@Override
public void run()
{
callback.onFail();
}
});
} }
} }
}); });