ch.vorburger.mariadb4j.DBConfigurationBuilder Java Examples
The following examples show how to use
ch.vorburger.mariadb4j.DBConfigurationBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractEmbeddedDataSourceHelper.java From freeacs with MIT License | 8 votes |
public static void setUpBeforeClass() throws ManagedProcessException { randomFolder = "./db/" + UUID.randomUUID(); DBConfigurationBuilder configBuilder = DBConfigurationBuilder.newBuilder(); configBuilder.setPort(3307); configBuilder.setDataDir(randomFolder); db = DB.newEmbeddedDB(configBuilder.build()); db.start(); db.createDB("acs", "acs", "acs"); db.source("install.sql", "acs", "acs", "acs"); String url = configBuilder.getURL("acs"); HikariConfig hikariConfig = new HikariConfig(); hikariConfig.setDataSourceClassName("org.mariadb.jdbc.MariaDbDataSource"); hikariConfig.addDataSourceProperty("url", url); hikariConfig.addDataSourceProperty("user", "acs"); hikariConfig.addDataSourceProperty("password", "acs"); dataSource = new HikariDataSource(hikariConfig); }
Example #2
Source File: MariaDBEmbeddedDb.java From mdw with Apache License 2.0 | 6 votes |
public void init(String url, String user, String password, String assetLocation, String baseLocation, String dataLocation) { this.url = url; URI uri = URI.create(url.substring(5)); this.port = uri.getPort(); this.dbName = uri.getPath().substring(1); this.user = user; this.password = password; DbConfigBuilder configBuilder = new DbConfigBuilder(); configBuilder.setPort(port); configBuilder.setBaseDir(baseLocation); configBuilder.setDataDir(dataLocation); String os = configBuilder.getOS(); String dbVer = configBuilder.getDbVersion(); dbJar = new File(assetLocation + "/" + DB_ASSET_PACKAGE.replace('.', '/') + "/mariaDB4j-db-" + os + "-" + dbVer.substring(8) + ".jar"); binariesSubLoc = DBConfigurationBuilder.class.getPackage().getName().replace('.', '/') + "/" + dbVer + "/" + os; configBuilder.setUnpackingFromClasspath(false); // we'll unpack it ourselves //configBuilder.addArg("--lower-case-table-names=1"); List<String> addlParams = PropertyManager.getInstance().getListProperty(PropertyNames.MDW_EMBEDDED_DB_STARTUP); if (addlParams != null) { for (String param : addlParams) { configBuilder.addArg(param); } } config = configBuilder.build(); }
Example #3
Source File: MySQLTestCore.java From rmlmapper-java with MIT License | 5 votes |
protected static DB setUpMySQLDBInstance(int portNumber) throws ManagedProcessException { DBConfigurationBuilder configBuilder = DBConfigurationBuilder.newBuilder(); configBuilder.setPort(portNumber); configBuilder.addArg("--user=root"); configBuilder.addArg("--sql-mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES"); DB mysqlDB = DB.newEmbeddedDB(configBuilder.build()); mysqlDB.start(); return mysqlDB; }
Example #4
Source File: TestDatabase.java From BungeeChat2 with GNU General Public License v3.0 | 5 votes |
@SneakyThrows(ManagedProcessException.class) @SuppressFBWarnings( // TODO: Remove when fixed in SpotBugs value = "RV_RETURN_VALUE_IGNORED", justification = "Return values can be safely ignored as they are for chaining only.") public static void startDatabase() { final int limit = 100; int count = 0; String actualBaseDir; String actualDataDir; do { actualBaseDir = baseDir + count; } while ((++count < limit) && (new File(actualBaseDir)).exists()); Preconditions.checkElementIndex(count, limit, "count must be less than " + limit); actualDataDir = actualBaseDir + "/data"; final DBConfiguration config = DBConfigurationBuilder.newBuilder() .setPort(0) .setSocket(localhost) .setBaseDir(actualBaseDir) .setDataDir(actualDataDir) .build(); databaseInstance = DB.newEmbeddedDB(config); databaseInstance.start(); port = databaseInstance.getConfiguration().getPort(); host = localhost + ':' + port; databaseInstance.createDB("test"); }
Example #5
Source File: App.java From hawkular-apm with Apache License 2.0 | 5 votes |
private DB createDatabase() throws ManagedProcessException { DBConfigurationBuilder configBuilder = DBConfigurationBuilder.newBuilder(); configBuilder.setPort(3306); configBuilder.setDataDir("target/mariaDB"); configBuilder.setBaseDir("target/mariaDB"); DB database = DB.newEmbeddedDB(configBuilder.build()); database.start(); return database; }
Example #6
Source File: DatabaseRule.java From CodeDefenders with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void before() throws Exception { config = DBConfigurationBuilder.newBuilder(); config.addArg("--user=root"); config.setPort(0); // 0 => autom. detect free port db = DB.newEmbeddedDB(config.build()); db.start(); db.createDB(dbName); db.source(initFile, username, password, dbName); }