當前位置: 首頁>>代碼示例>>Java>>正文


Java ManagedDatasource類代碼示例

本文整理匯總了Java中vg.civcraft.mc.civmodcore.dao.ManagedDatasource的典型用法代碼示例。如果您正苦於以下問題:Java ManagedDatasource類的具體用法?Java ManagedDatasource怎麽用?Java ManagedDatasource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ManagedDatasource類屬於vg.civcraft.mc.civmodcore.dao包,在下文中一共展示了ManagedDatasource類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: provisionDatabase

import vg.civcraft.mc.civmodcore.dao.ManagedDatasource; //導入依賴的package包/類
private boolean provisionDatabase(ConfigurationSection config) {
	String host = config.getString("host", "localhost");
	int port = config.getInt("port", 3306);
	String dbname = config.getString("database", "ipcheck");
	String username = config.getString("user");
	String password = config.getString("password");
	int poolsize = config.getInt("poolsize", 3);
	long connectionTimeout = config.getLong("connection_timeout", 10000l);
	long idleTimeout = config.getLong("idle_timeout", 600000l);
	long maxLifetime = config.getLong("max_lifetime", 7200000l);
	try {
		internalDatabase = new ManagedDatasource(BanStick.getPlugin(), username, password, host, port, dbname,
				poolsize, connectionTimeout, idleTimeout, maxLifetime);
		internalDatabase.getConnection().close();
	} catch (Exception se) {
		BanStick.getPlugin().info("Failed to initialize Database connection");
		return false;
	}
	
	return true;
}
 
開發者ID:ProgrammerDan,項目名稱:BanStick,代碼行數:22,代碼來源:IpCheckImportWorker.java

示例2: setupDatabase

import vg.civcraft.mc.civmodcore.dao.ManagedDatasource; //導入依賴的package包/類
@CivConfigs({
	@CivConfig(name = "mysql.host", def = "localhost", type = CivConfigType.String),
	@CivConfig(name = "mysql.port", def = "3306", type = CivConfigType.Int),
	@CivConfig(name = "mysql.username", type = CivConfigType.String),
	@CivConfig(name = "mysql.password", type = CivConfigType.String),
	@CivConfig(name = "mysql.dbname", def = "BetterShardsDB", type = CivConfigType.String),
	@CivConfig(name = "mysql.poolsize", def = "10", type = CivConfigType.Int),
	@CivConfig(name = "mysql.connection_timeout", def = "10000", type = CivConfigType.Long),
	@CivConfig(name = "mysql.idle_timeout", def = "600000", type = CivConfigType.Long),
	@CivConfig(name = "mysql.max_lifetime", def = "7200000", type = CivConfigType.Long)
})
private void setupDatabase(){
	String username = config.get("mysql.username").getString();
	String host = config.get("mysql.host").getString();
	int port = config.get("mysql.port").getInt();
	String password = config.get("mysql.password").getString();
	String dbname = config.get("mysql.dbname").getString();
	int poolsize = config.get("mysql.poolsize").getInt();
	long connectionTimeout = config.get("mysql.connection_timeout").getLong();
	long idleTimeout = config.get("mysql.idle_timeout").getLong();
	long maxLifetime = config.get("mysql.max_lifetime").getLong();
	this.db = new ManagedDatasource(plugin, username, password, host, port, dbname, poolsize, connectionTimeout, idleTimeout, maxLifetime);
}
 
開發者ID:Civcraft,項目名稱:BetterShards,代碼行數:24,代碼來源:DatabaseManager.java

示例3: configureData

import vg.civcraft.mc.civmodcore.dao.ManagedDatasource; //導入依賴的package包/類
private boolean configureData(ConfigurationSection config) {
	String host = config.getString("host", "localhost");
	int port = config.getInt("port", 3306);
	String dbname = config.getString("database", "cropcontrol");
	String username = config.getString("user");
	String password = config.getString("password");
	int poolsize = config.getInt("poolsize", 5);
	long connectionTimeout = config.getLong("connection_timeout", 10000l);
	long idleTimeout = config.getLong("idle_timeout", 600000l);
	long maxLifetime = config.getLong("max_lifetime", 7200000l);
	try {
		data = new ManagedDatasource(CropControl.getPlugin(), username, password, host, port, dbname,
				poolsize, connectionTimeout, idleTimeout, maxLifetime);
		data.getConnection().close();
	} catch (Exception se) {
		CropControl.getPlugin().info("Failed to initialize Database connection");
		return false;
	}

	initializeTables();		
	stageUpdates();
	
	long begin_time = System.currentTimeMillis();

	try {
		CropControl.getPlugin().info("Update prepared, starting database update.");
		if (!data.updateDatabase()) {
			CropControl.getPlugin().info( "Update failed, disabling plugin.");
			return false;
		}
	} catch (Exception e) {
		CropControl.getPlugin().severe("Update failed, disabling plugin. Cause:", e);
		return false;
	}

	CropControl.getPlugin().info(String.format("Database update took %d seconds", (System.currentTimeMillis() - begin_time) / 1000));
	
	activateDirtySave(config.getConfigurationSection("dirtysave"));
	return true;
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:41,代碼來源:CropControlDatabaseHandler.java

示例4: getData

import vg.civcraft.mc.civmodcore.dao.ManagedDatasource; //導入依賴的package包/類
public ManagedDatasource getData() {
	return this.data;
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:4,代碼來源:CropControlDatabaseHandler.java

示例5: getInstanceData

import vg.civcraft.mc.civmodcore.dao.ManagedDatasource; //導入依賴的package包/類
public static ManagedDatasource getInstanceData() {
	return CropControlDatabaseHandler.instance.data;
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:4,代碼來源:CropControlDatabaseHandler.java

示例6: getinstanceData

import vg.civcraft.mc.civmodcore.dao.ManagedDatasource; //導入依賴的package包/類
public static ManagedDatasource getinstanceData() {
	return BanStickDatabaseHandler.instance.data;
}
 
開發者ID:ProgrammerDan,項目名稱:BanStick,代碼行數:4,代碼來源:BanStickDatabaseHandler.java

示例7: configureData

import vg.civcraft.mc.civmodcore.dao.ManagedDatasource; //導入依賴的package包/類
private boolean configureData(ConfigurationSection config) {
	String host = config.getString("host", "localhost");
	int port = config.getInt("port", 3306);
	String dbname = config.getString("database", "banstick");
	String username = config.getString("user");
	String password = config.getString("password");
	int poolsize = config.getInt("poolsize", 5);
	long connectionTimeout = config.getLong("connection_timeout", 10000l);
	long idleTimeout = config.getLong("idle_timeout", 600000l);
	long maxLifetime = config.getLong("max_lifetime", 7200000l);
	try {
		data = new ManagedDatasource(BanStick.getPlugin(), username, password, host, port, dbname,
				poolsize, connectionTimeout, idleTimeout, maxLifetime);
		data.getConnection().close();
	} catch (Exception se) {
		BanStick.getPlugin().info("Failed to initialize Database connection");
		return false;
	}

	initializeTables();		
	stageUpdates();
	
	long begin_time = System.currentTimeMillis();

	try {
		BanStick.getPlugin().info("Update prepared, starting database update.");
		if (!data.updateDatabase()) {
			BanStick.getPlugin().info( "Update failed, disabling plugin.");
			return false;
		}
	} catch (Exception e) {
		BanStick.getPlugin().severe("Update failed, disabling plugin. Cause:", e);
		return false;
	}

	BanStick.getPlugin().info(String.format("Database update took %d seconds", (System.currentTimeMillis() - begin_time) / 1000));
	
	activatePreload(config.getConfigurationSection("preload"));
	activateDirtySave(config.getConfigurationSection("dirtysave"));
	return true;
}
 
開發者ID:ProgrammerDan,項目名稱:BanStick,代碼行數:42,代碼來源:BanStickDatabaseHandler.java


注:本文中的vg.civcraft.mc.civmodcore.dao.ManagedDatasource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。