public void setActiveDatabase(Database db) throws DBException { this.db.close(); this.db = db; }
@Override public void run() { database.save().playerWasKicked(uuid); } }
/** * Constructor. * * @param name Name of the table in the db. * @param db Database to use. */ public Table(String name, SQLDB db) { this.tableName = name; this.db = db; this.supportsMySQLQueries = db != null && db.getType().supportsMySQLQueries(); }
@Override public void enable() throws EnableException { try { db.init(); db.scheduleClean(20L); logger.info(locale.getString(PluginLang.ENABLED_DATABASE, db.getType().getName())); } catch (DBInitException e) { Throwable cause = e.getCause(); String message = cause == null ? e.getMessage() : cause.getMessage(); throw new EnableException(db.getType().getName() + " init failure: " + message, cause); } }
@Override public void run() { database.save().commandUsed(command); } }
/** * Checks if the name of a {@code DBType} corresponds to {@code name}.<p> * This method is case-insensitive. * * @param name the name of the {@code DBType} * @return if the {@code DBType} exists * @see DBType#getForName(String) */ public static boolean exists(String name) { for (DBType dbType : DBType.values()) { if (dbType.getName().equalsIgnoreCase(name)) { return true; } } return false; } }
@Override public String getPlayerName(UUID uuid) { return dbSystem.getDatabase().fetch().getPlayerName(uuid); }
public Database getActiveDatabaseByName(String dbName) { for (Database database : getDatabases()) { String dbConfigName = database.getType().getConfigName(); if (Verify.equalsIgnoreCase(dbName, dbConfigName)) { return database; } } throw new IllegalArgumentException(locale.getString(PluginLang.ENABLE_FAIL_WRONG_DB, dbName)); }
private String getRenameTableSQL(String from, String to) { switch (dbType) { case SQLITE: return "ALTER TABLE " + from + " RENAME TO " + to; case MYSQL: return "RENAME TABLE " + from + " TO " + to; case H2: return "ALTER TABLE " + from + " RENAME TO " + to; default: throw new IllegalArgumentException("DBType: " + dbType.getName() + " does not have rename table sql"); } }
@Override public FetchOperations fetchFromPlanDB() { return dbSystem.getDatabase().fetch(); } }
protected void addColumn(String tableName, String columnInfo) { db.execute("ALTER TABLE " + tableName + " ADD " + (dbType.supportsMySQLQueries() ? "" : "COLUMN ") + columnInfo); }
private void registerConfigSettingGraphs() { String serverType = plugin.getProxy().getName(); String databaseType = database.getType().getName(); addStringSettingPie("server_type", serverType); addStringSettingPie("database_type", databaseType); addStringSettingPie("network_servers", connectionSystem.getBukkitServers().size()); }
@Override public String getPlayerName(UUID uuid) { return dbSystem.getDatabase().fetch().getPlayerName(uuid); }
@Override public FetchOperations fetchFromPlanDB() { return dbSystem.getDatabase().fetch(); } }
@Override public void disable() { try { if (db != null) { db.close(); } } catch (DBException e) { errorHandler.log(L.WARN, this.getClass(), e); } }