mirror of
https://github.com/geekfrog/PermissionsTime.git
synced 2025-09-08 18:45:38 +00:00
mysql支持,修改bug
This commit is contained in:
@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import gg.frog.mc.permissionstime.PluginMain;
|
||||
import gg.frog.mc.permissionstime.config.PluginCfg;
|
||||
import gg.frog.mc.permissionstime.database.impl.MySQLPlayerDataService;
|
||||
import gg.frog.mc.permissionstime.database.impl.SqlitePlayerDataService;
|
||||
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
|
||||
import gg.frog.mc.permissionstime.utils.StrUtil;
|
||||
@ -32,20 +33,23 @@ public class SqlManager {
|
||||
}
|
||||
if (PluginCfg.USE_MYSQL) {
|
||||
db = new MySQL(PluginMain.LOG, "[" + pm.PLUGIN_NAME + "] ", PluginCfg.SQL_HOSTNAME, PluginCfg.SQL_PORT, PluginCfg.SQL_DATABASE, PluginCfg.SQL_USERNAME, PluginCfg.SQL_PASSWORD);
|
||||
pds = new MySQLPlayerDataService(pm, this);
|
||||
} else {
|
||||
db = new SQLite(PluginMain.LOG, "[" + pm.PLUGIN_NAME + "] ", pm.getDataFolder().getAbsolutePath(), "playerData", ".db");
|
||||
pds = new SqlitePlayerDataService(pm, this);
|
||||
}
|
||||
db.open();
|
||||
try {
|
||||
if (!pds.tableExist()) {
|
||||
pds.creatTable();
|
||||
if(db.open()) {
|
||||
try {
|
||||
if (!pds.tableExist()) {
|
||||
pds.creatTable();
|
||||
}
|
||||
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX) + "连接数据库成功");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX) + "连接数据库成功");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX) + "连接数据库失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user