use of com.mysql.cj.jdbc.MysqlConnectionPoolDataSource in project narayana by jbosstm.
the class PerformanceTestCommitMarkableResource method testCommitMarkableResource.
// @org.junit.Ignore
@Test
public void testCommitMarkableResource() throws Exception {
System.out.println("testCommitMarkableResource: " + new Date());
ConnectionPoolDataSource dataSource = null;
DataSource recoveryDataSource = null;
if (dbType.equals("oracle")) {
// ORA-01795: maximum number of expressions in a list is 1000
BeanPopulator.getDefaultInstance(JTAEnvironmentBean.class).setCommitMarkableResourceRecordDeleteBatchSize(1000);
Class clazz = Class.forName("oracle.jdbc.pool.OracleConnectionPoolDataSource");
dataSource = (ConnectionPoolDataSource) clazz.newInstance();
clazz.getMethod("setDriverType", new Class[] { String.class }).invoke(dataSource, new Object[] { "thin" });
clazz.getMethod("setServerName", new Class[] { String.class }).invoke(dataSource, new Object[] { "tywin.eng.hst.ams2.redhat.com" });
clazz.getMethod("setNetworkProtocol", new Class[] { String.class }).invoke(dataSource, new Object[] { "tcp" });
clazz.getMethod("setDatabaseName", new Class[] { String.class }).invoke(dataSource, new Object[] { "orcl" });
clazz.getMethod("setUser", new Class[] { String.class }).invoke(dataSource, new Object[] { "dtf11" });
clazz.getMethod("setPassword", new Class[] { String.class }).invoke(dataSource, new Object[] { "dtf11" });
clazz.getMethod("setPortNumber", new Class[] { int.class }).invoke(dataSource, new Object[] { 1521 });
recoveryDataSource = (DataSource) dataSource;
} else if (dbType.equals("sybase")) {
// wide table support?
BeanPopulator.getDefaultInstance(JTAEnvironmentBean.class).setCommitMarkableResourceRecordDeleteBatchSize(2000);
Class clazz = Class.forName("com.sybase.jdbc3.jdbc.SybConnectionPoolDataSource");
dataSource = (ConnectionPoolDataSource) clazz.newInstance();
clazz.getMethod("setServerName", new Class[] { String.class }).invoke(dataSource, new Object[] { "192.168.1.5" });
clazz.getMethod("setDatabaseName", new Class[] { String.class }).invoke(dataSource, new Object[] { "LOCALHOST" });
clazz.getMethod("setUser", new Class[] { String.class }).invoke(dataSource, new Object[] { "sa" });
clazz.getMethod("setPassword", new Class[] { String.class }).invoke(dataSource, new Object[] { "sybase" });
clazz.getMethod("setPortNumber", new Class[] { int.class }).invoke(dataSource, new Object[] { 5000 });
Class clazz2 = Class.forName("com.sybase.jdbc3.jdbc.SybDataSource");
recoveryDataSource = (DataSource) clazz2.newInstance();
clazz2.getMethod("setServerName", new Class[] { String.class }).invoke(recoveryDataSource, new Object[] { "192.168.1.5" });
clazz2.getMethod("setDatabaseName", new Class[] { String.class }).invoke(recoveryDataSource, new Object[] { "LOCALHOST" });
clazz2.getMethod("setUser", new Class[] { String.class }).invoke(recoveryDataSource, new Object[] { "sa" });
clazz2.getMethod("setPassword", new Class[] { String.class }).invoke(recoveryDataSource, new Object[] { "sybase" });
clazz2.getMethod("setPortNumber", new Class[] { int.class }).invoke(recoveryDataSource, new Object[] { 5000 });
} else if (dbType.equals("h2")) {
// Smaller batch size as H2 uses a hashtable in the delete which is
// inefficent for bytearray clause
BeanPopulator.getDefaultInstance(JTAEnvironmentBean.class).setCommitMarkableResourceRecordDeleteBatchSize(100);
dataSource = new JdbcDataSource();
((JdbcDataSource) dataSource).setURL("jdbc:h2:mem:JBTMDB;MVCC=TRUE;DB_CLOSE_DELAY=-1");
recoveryDataSource = ((JdbcDataSource) dataSource);
} else if (dbType.equals("postgres")) {
dataSource = new PGConnectionPoolDataSource();
((PGConnectionPoolDataSource) dataSource).setPortNumber(5432);
((PGConnectionPoolDataSource) dataSource).setUser("dtf11");
((PGConnectionPoolDataSource) dataSource).setPassword("dtf11");
((PGConnectionPoolDataSource) dataSource).setServerName("tywin.eng.hst.ams2.redhat.com");
((PGConnectionPoolDataSource) dataSource).setDatabaseName("jbossts");
recoveryDataSource = new PGSimpleDataSource();
((PGSimpleDataSource) recoveryDataSource).setPortNumber(5432);
((PGSimpleDataSource) recoveryDataSource).setUser("dtf11");
((PGSimpleDataSource) recoveryDataSource).setPassword("dtf11");
((PGSimpleDataSource) recoveryDataSource).setServerName("tywin.eng.hst.ams2.redhat.com");
((PGSimpleDataSource) recoveryDataSource).setDatabaseName("jbossts");
} else if (dbType.equals("mysql")) {
// com.mysql.jdbc.PacketTooBigException: Packet for query is too
// large (1318148 > 1048576). You can change this value on the
// server by setting the max_allowed_packet' variable
BeanPopulator.getDefaultInstance(JTAEnvironmentBean.class).setCommitMarkableResourceRecordDeleteBatchSize(3500);
dataSource = new MysqlConnectionPoolDataSource();
// need paranoid as otherwise it sends a connection change user
((MysqlConnectionPoolDataSource) dataSource).setUrl("jdbc:mysql://tywin.eng.hst.ams2.redhat.com:3306/jbossts?user=dtf11&password=dtf11¶noid=true");
recoveryDataSource = (DataSource) dataSource;
} else if (dbType.equals("db2")) {
Class clazz = Class.forName("com.ibm.db2.jcc.DB2ConnectionPoolDataSource");
dataSource = (ConnectionPoolDataSource) clazz.newInstance();
clazz.getMethod("setServerName", new Class[] { String.class }).invoke(dataSource, new Object[] { "tywin.eng.hst.ams2.redhat.com" });
clazz.getMethod("setDatabaseName", new Class[] { String.class }).invoke(dataSource, new Object[] { "BTDB1" });
clazz.getMethod("setUser", new Class[] { String.class }).invoke(dataSource, new Object[] { "db2" });
clazz.getMethod("setPassword", new Class[] { String.class }).invoke(dataSource, new Object[] { "db2" });
clazz.getMethod("setDriverType", new Class[] { int.class }).invoke(dataSource, new Object[] { 4 });
clazz.getMethod("setPortNumber", new Class[] { int.class }).invoke(dataSource, new Object[] { 50001 });
Class clazz2 = Class.forName("com.ibm.db2.jcc.DB2DataSource");
recoveryDataSource = (DataSource) clazz2.newInstance();
clazz2.getMethod("setServerName", new Class[] { String.class }).invoke(recoveryDataSource, new Object[] { "tywin.eng.hst.ams2.redhat.com" });
clazz2.getMethod("setDatabaseName", new Class[] { String.class }).invoke(recoveryDataSource, new Object[] { "BTDB1" });
clazz2.getMethod("setUser", new Class[] { String.class }).invoke(recoveryDataSource, new Object[] { "db2" });
clazz2.getMethod("setPassword", new Class[] { String.class }).invoke(recoveryDataSource, new Object[] { "db2" });
clazz2.getMethod("setDriverType", new Class[] { int.class }).invoke(recoveryDataSource, new Object[] { 4 });
clazz2.getMethod("setPortNumber", new Class[] { int.class }).invoke(recoveryDataSource, new Object[] { 50001 });
} else if (dbType.equals("sqlserver")) {
Class clazz = Class.forName("com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource");
dataSource = (ConnectionPoolDataSource) clazz.newInstance();
clazz.getMethod("setServerName", new Class[] { String.class }).invoke(dataSource, new Object[] { "dev30.mw.lab.eng.bos.redhat.com" });
clazz.getMethod("setDatabaseName", new Class[] { String.class }).invoke(dataSource, new Object[] { "dballo01" });
clazz.getMethod("setUser", new Class[] { String.class }).invoke(dataSource, new Object[] { "dballo01" });
clazz.getMethod("setPassword", new Class[] { String.class }).invoke(dataSource, new Object[] { "dballo01" });
clazz.getMethod("setSendStringParametersAsUnicode", new Class[] { Boolean.class }).invoke(dataSource, new Object[] { false });
clazz.getMethod("setPortNumber", new Class[] { int.class }).invoke(dataSource, new Object[] { 3918 });
recoveryDataSource = (DataSource) dataSource;
}
PooledConnection pooledConnection = dataSource.getPooledConnection();
Utils.createTables(pooledConnection.getConnection());
doTest(new Handler(dataSource, recoveryDataSource), "_testCommitMarkableResource_" + dbType);
}
use of com.mysql.cj.jdbc.MysqlConnectionPoolDataSource in project rome-plugin by christianbookout.
the class RomePlugin method onEnable.
// runs when the plugin is enabled on the server startup
@Override
public void onEnable() {
this.saveDefaultConfig();
FileConfiguration config = this.getConfig();
MysqlDataSource dataSource = new MysqlConnectionPoolDataSource();
// we set our credentials
dataSource.setServerName(config.getString("database.host"));
dataSource.setPortNumber(config.getInt("database.port"));
dataSource.setDatabaseName(config.getString("database.database"));
dataSource.setUser(config.getString("database.username"));
dataSource.setPassword(config.getString("database.password"));
Material claimMaterial;
String claimMaterialStr = config.getString("claims.claimMaterial");
var protectedMaterialStrings = config.getStringList("claims.autoLockedBlocks");
try {
claimMaterial = Material.valueOf(claimMaterialStr.toUpperCase().strip());
} catch (IllegalArgumentException e) {
this.getLogger().log(Level.WARNING, "error getting minecraft material from " + claimMaterialStr);
claimMaterial = LandEventListener.DEFAULT_MATERIAL;
}
var protectedMaterials = new HashSet<Material>();
protectedMaterialStrings.forEach(matStr -> protectedMaterials.add(Material.valueOf(matStr)));
var lockManager = new LockManager(this);
SQLConn.setSource(dataSource);
try (Connection conn = SQLConn.getConnection()) {
conn.prepareStatement("CREATE TABLE IF NOT EXISTS titles (" + "uuid CHAR(36) NOT NULL PRIMARY KEY," + "title " + TITLE_ENUM + " NOT NULL);").execute();
conn.prepareStatement("CREATE TABLE IF NOT EXISTS builders (" + "uuid CHAR(36) NOT NULL PRIMARY KEY);").execute();
// (x0, y0) must be the top-left point and (x1, y1) must be the bottom-right
// point
conn.prepareStatement("CREATE TABLE IF NOT EXISTS cityClaims (" + "x0 INT NOT NULL," + "y0 INT NOT NULL," + "x1 INT NOT NULL," + "y1 INT NOT NULL," + "owner_uuid CHAR(36) NOT NULL);").execute();
conn.prepareStatement("CREATE TABLE IF NOT EXISTS strawberry (" + "x0 INT NOT NULL," + "y0 INT NOT NULL," + "x1 INT NOT NULL," + "y1 INT NOT NULL," + "added_player_uuid CHAR(36) NOT NULL);").execute();
conn.prepareStatement("CREATE TABLE IF NOT EXISTS usernames (" + "uuid CHAR(36) NOT NULL PRIMARY KEY," + "username CHAR(32) NOT NULL);").execute();
// all players extra claim blocks
conn.prepareStatement("CREATE TABLE IF NOT EXISTS extraClaimBlocks (" + "uuid CHAR(36) NOT NULL PRIMARY KEY," + "blocks INT NOT NULL DEFAULT 0);").execute();
// fun lock stuff
conn.prepareStatement("CREATE TABLE IF NOT EXISTS lockedBlocks (" + "x INT NOT NULL," + "y INT NOT NULL," + "z INT NOT NULL," + "keyId INT NOT NULL);").execute();
conn.prepareStatement("CREATE TABLE IF NOT EXISTS lockKeys (" + "keyId INT NOT NULL AUTO_INCREMENT PRIMARY KEY," + "creator_uuid CHAR(36) NOT NULL);").execute();
conn.prepareStatement("CREATE TABLE IF NOT EXISTS banished (" + "uuid CHAR(36) NOT NULL PRIMARY KEY);").execute();
} catch (SQLException e) {
e.printStackTrace();
}
var roleHandler = new RoleHandler();
var cityManager = new CityManager(config.getInt("land.initialCitySize"), config.getInt("land.cityMultiplier"), config.getInt("land.suburbsMultiplier"), config.getInt("claims.defaultClaimBlocks"), roleHandler);
LandEventListener landListener = new LandEventListener(cityManager, lockManager, claimMaterial, protectedMaterials, config.getLong("claims.claimTimeoutMS"));
var titles = new TitleHandler(this);
PartyHandler partyHandler = new PartyHandler();
var empireHandler = new EmpireHandler(partyHandler);
SwearFilter filter = new SwearFilter(cityManager, SwearLevel.valueOf(config.getString("messages.useSwearFilter").toUpperCase()));
var landEnterListener = new LandEnterListener(cityManager);
var peeController = new PeeController(this);
// var itemBank = new ItemBank(this);
var notifications = new NotificationQueue();
getCommand("city").setExecutor(new CityCommand(cityManager));
getCommand("claim").setExecutor(new ClaimLandCommand(cityManager));
getCommand("claiminfo").setExecutor(new ClaimInfoCommand());
getCommand("removetitle").setExecutor(new RemoveTitleCommand(titles));
getCommand("settitle").setExecutor(new SetTitleCommand(titles));
// getCommand("bal").setExecutor(new BalanceCommand(ledger));
getServer().getPluginManager().registerEvents(new RemovePopeListener(roleHandler), this);
getCommand("builder").setExecutor(new BuilderCommand());
getCommand("shout").setExecutor(new ShoutCommand(partyHandler, roleHandler));
getCommand("pee").setExecutor(peeController);
// getCommand("makekey").setExecutor(new MakeKeyCommand(lockManager));
getCommand("getblocks").setExecutor(new GetClaimBlocksCommand(cityManager));
getCommand("elections").setExecutor(new ElectionCommand(new ElectionHandler(notifications, this, roleHandler), empireHandler, roleHandler));
getCommand("elections").setTabCompleter(new ElectionTabCompleter());
getCommand("titles").setExecutor(new TitlesCommand());
getCommand("parties").setExecutor(new PartyCommand(partyHandler));
// getCommand("itembank").setExecutor(itemBank);
getCommand("notification").setExecutor(new NotificationCommand(notifications));
// getServer().getPluginManager().registerEvents(itemBank, this);
getCommand("spawn").setExecutor(new SpawnCommand(cityManager));
getCommand("banish").setExecutor(new BanishCommand(landEnterListener, roleHandler));
getServer().getPluginManager().registerEvents(peeController, this);
getServer().getPluginManager().registerEvents(new RoleEventListener(roleHandler, partyHandler), this);
getServer().getPluginManager().registerEvents(new DistanceListener(config.getInt("messages.messageDistance"), filter, cityManager), this);
// getServer().getPluginManager().registerEvents(new BlockchainEventListener(this, ledger), this);
getServer().getPluginManager().registerEvents(landListener, this);
getServer().getPluginManager().registerEvents(lockManager, this);
getServer().getPluginManager().registerEvents(landEnterListener, this);
}
use of com.mysql.cj.jdbc.MysqlConnectionPoolDataSource in project FrameworkBenchmarks by TechEmpower.
the class MysqlConfig method configureMysqlConnections.
private MysqlConnectionPoolDataSource configureMysqlConnections(String uri, String dbUser, String dbPassword, String useConfigs) {
MysqlConnectionPoolDataSource ds = new MysqlConnectionPoolDataSource();
ds.setUrl(uri);
if (dbUser != null) {
ds.setUser(dbUser);
}
if (dbPassword != null) {
ds.setPassword(dbPassword);
}
if (useConfigs != null) {
try {
ds.setUseConfigs(useConfigs);
} catch (java.sql.SQLException e) {
throw new ConfigurationException("Unable to set DataSource config", e);
}
}
return ds;
}
use of com.mysql.cj.jdbc.MysqlConnectionPoolDataSource in project LemBot by Leminee.
the class DatabaseConnector method setupDataSource.
private static void setupDataSource() {
DatabaseConfig config = Config.getInstance().getDatabaseConfig();
dataSource = new MysqlConnectionPoolDataSource();
dataSource.setURL(config.getUrl());
dataSource.setUser(config.getUsername());
dataSource.setPassword(config.getPassword());
}
Aggregations