当前位置: 首页>>代码示例>>Java>>正文


Java MysqldResource.start方法代码示例

本文整理汇总了Java中com.mysql.management.MysqldResource.start方法的典型用法代码示例。如果您正苦于以下问题:Java MysqldResource.start方法的具体用法?Java MysqldResource.start怎么用?Java MysqldResource.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mysql.management.MysqldResource的用法示例。


在下文中一共展示了MysqldResource.start方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import com.mysql.management.MysqldResource; //导入方法依赖的package包/类
@Override
public String start() {
  Map<String,String> args = new HashMap<>();
  args.put(MysqldResourceI.PORT, Integer.toString(DB_PORT));
  args.put(MysqldResourceI.INITIALIZE_USER, "true");
  args.put(MysqldResourceI.INITIALIZE_USER_NAME, DB_USER);
  args.put(MysqldResourceI.INITIALIZE_PASSWORD, DB_PASS);
  engine = new MysqldResource(new File(DB_PATH));
  engine.start("jdbdt-mysqld-thread", args);

  if (!engine.isRunning()) {
    throw new RuntimeException("MySQL did not start.");
  }

  return String.format
      (
          "jdbc:mysql://127.0.0.1:%d/jdbdt?user=%s&password=%s&createDatabaseIfNotExist=true", 
          DB_PORT, 
          DB_USER, 
          DB_PASS
          );
}
 
开发者ID:edrdo,项目名称:jdbdt,代码行数:23,代码来源:MySQLDBSetup.java

示例2: setUp

import com.mysql.management.MysqldResource; //导入方法依赖的package包/类
public void setUp() {
    File databaseDir = new File(new File(baseDatabaseDir), databaseName);
    
    PrintStream nps = this.getNullAppender();
    mysqldResource = new MysqldResource(databaseDir, null, null, nps, nps);        
    
    Map<String, String> database_options = new HashMap<String, String>();
    database_options.put(MysqldResourceI.PORT, Integer.toString(port));
    database_options.put(MysqldResourceI.INITIALIZE_USER, "true");
    database_options.put(MysqldResourceI.INITIALIZE_USER_NAME, username);
    database_options.put(MysqldResourceI.INITIALIZE_PASSWORD, password);        
    
    mysqldResource.start("embedded-mysqld-thread-" + System.currentTimeMillis(), database_options);

    if (!mysqldResource.isRunning()) {
        throw new RuntimeException("MySQL did not start.");
    }
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:19,代码来源:EmbeddedMySQLDb.java

示例3: EmbeddedMySQL

import com.mysql.management.MysqldResource; //导入方法依赖的package包/类
private EmbeddedMySQL() throws InterruptedException
{
    port = AvailablePortFinder.getNextAvailable(internalCounter.getAndIncrement());

    dataDir = Files.createTempDir();

    mysqld = new MysqldResource(dataDir);

    Map<String, String> props = ImmutableMap.of(MysqldResourceI.PORT, Integer.toString(port),
                                                MysqldResourceI.INITIALIZE_USER, "true",
                                                MysqldResourceI.INITIALIZE_USER_NAME, "user",
                                                MysqldResourceI.INITIALIZE_PASSWORD, "pass",
                                                "default-time-zone", "+00:00");
    mysqld.start("mysql-daemon", props);
    if (!mysqld.isRunning()) {
        throw new IllegalStateException("MySQL failed to start");
    }
    while (!mysqld.isReadyForConnections()) { Thread.sleep(100); }
}
 
开发者ID:groupon,项目名称:mysql-junit4,代码行数:20,代码来源:EmbeddedMySQL.java

示例4: startDb

import com.mysql.management.MysqldResource; //导入方法依赖的package包/类
/**
 * Start the database.
 */
public void startDb() {
  Map<String, String> databaseOptions = new HashMap<>();
  databaseOptions.put(MysqldResourceI.PORT, Integer.toString(port));

  mysqldResource = new MysqldResource(new File(databaseDir, databaseName));
  mysqldResource.start("embedded-mysqld-db-thread-" + System.currentTimeMillis(),
      databaseOptions);

  if (!mysqldResource.isRunning()) {
    throw new RuntimeException("Failed to start embedded MySQL DB!");
  }

  LOG.debug("MySQL started successfully");
}
 
开发者ID:airbnb,项目名称:reair,代码行数:18,代码来源:EmbeddedMySqlDb.java

示例5: start

import com.mysql.management.MysqldResource; //导入方法依赖的package包/类
public void start(String databaseName) {
    String tmpDir = System.getProperty("java.io.tmpdir");
    File baseDir = new File(tmpDir, databaseName);
    FileUtils.deleteQuietly(baseDir);
    int port = getFreePort();

    Map<String, String> databaseOptions = new HashMap<>();
    databaseOptions.put(MysqldResourceI.PORT, Integer.toString(port));

    mysqldResource = new MysqldResource(baseDir);
    mysqldResource.start("mysql", databaseOptions);

    url = "jdbc:mysql://localhost:" + port + "/" + databaseName + "?" + "createDatabaseIfNotExist=true";
}
 
开发者ID:aerogear,项目名称:aerogear-unifiedpush-server,代码行数:15,代码来源:EmbeddedMysqlDatabase.java


注:本文中的com.mysql.management.MysqldResource.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。