本文整理汇总了Java中ch.vorburger.mariadb4j.DB.start方法的典型用法代码示例。如果您正苦于以下问题:Java DB.start方法的具体用法?Java DB.start怎么用?Java DB.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.vorburger.mariadb4j.DB
的用法示例。
在下文中一共展示了DB.start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enableDatabaseMySQLTest
import ch.vorburger.mariadb4j.DB; //导入方法依赖的package包/类
@Test
public void enableDatabaseMySQLTest() {
try {
final DB database = DB.newEmbeddedDB(3306);
database.start();
try (Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/?user=root&password=")) {
try (Statement statement = conn.createStatement()) {
statement.executeUpdate("CREATE DATABASE db");
}
}
final HikariConfig config = new HikariConfig();
config.setDriverClassName("com.mysql.jdbc.Driver");
config.setConnectionTestQuery("SELECT 1");
config.setJdbcUrl("jdbc:mysql://localhost:3306/db");
config.setMaxLifetime(60000);
config.setIdleTimeout(45000);
config.setMaximumPoolSize(50);
final HikariDataSource ds = new HikariDataSource(config);
ds.close();
database.stop();
} catch (final Exception ex) {
Logger.getLogger(this.getClass().getSimpleName()).log(Level.WARNING, "Failed to enable database.", ex);
Assert.fail();
}
}
示例2: enableDatabaseMySQLTest
import ch.vorburger.mariadb4j.DB; //导入方法依赖的package包/类
@Test
public void enableDatabaseMySQLTest() {
try {
final DB database = DB.newEmbeddedDB(3306);
database.start();
try (Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/?user=root&password=")) {
try (Statement statement = conn.createStatement()) {
statement.executeUpdate("CREATE DATABASE db");
}
}
final HikariConfig config = new HikariConfig();
config.setDriverClassName("com.mysql.jdbc.Driver");
config.setConnectionTestQuery("SELECT 1");
config.setJdbcUrl("jdbc:mysql://localhost:3306/db");
config.setMaxLifetime(60000);
config.setIdleTimeout(45000);
config.setMaximumPoolSize(50);
final HikariDataSource ds = new HikariDataSource(config);
ds.close();
database.stop();
} catch (final Exception ex) {
Logger.getLogger(this.getClass().getSimpleName()).log(Level.WARNING, "Failed to enable database.", ex);
Assertions.fail(ex);
}
}
示例3: createDatabase
import ch.vorburger.mariadb4j.DB; //导入方法依赖的package包/类
private static DB createDatabase(JsonObject config) {
config.put("user", "root");
config.remove("password");
try {
DB db = DB.newEmbeddedDB(3366);
db.start();
return db;
} catch (ManagedProcessException e) {
LOG.debug("DB startup failed", e);
throw new RuntimeException(e.getCause());
}
}
示例4: createDatabase
import ch.vorburger.mariadb4j.DB; //导入方法依赖的package包/类
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;
}