Package com.mysql.management

Examples of com.mysql.management.MysqldResource


      }
      log.info("Deleting contents of: " + config.residentFolder);
      FileUtils.deleteDirectory(config.residentFolder);
    }
    log.info("Using config: " + config);
    MysqldResource mysqldResource = new MysqldResource(config.residentFolder);
    Map database_options = new HashMap();
    database_options.put(MysqldResourceI.PORT, Integer.toString(config.port));
    database_options.put(MysqldResourceI.INITIALIZE_USER, "true");
    database_options.put(MysqldResourceI.INITIALIZE_USER_NAME, config.user);
    database_options.put(MysqldResourceI.INITIALIZE_PASSWORD, config.pass);
    log.info("Using user: " + System.getProperty("user.name"));
    database_options.put("user", System.getProperty("user.name"));
    if(config.customConfig != null) {
      for(Map.Entry<String, Object> entry : config.customConfig.entrySet()) {
        database_options.put(entry.getKey(), entry.getValue());
      }
    }
    // I have to do this checking myself, otherwise in some cases mysqldResource will block undefinitely...
    try {
      ServerSocket serverSocket = new ServerSocket(config.port);
      serverSocket.close();
    } catch(IOException e) {
      throw new RuntimeException("Port already in use: " + config.port);
    }
    if(mysqldResource.isRunning()) {
      throw new RuntimeException("MySQL already running!");
    }
    mysqldResource.start("test-mysqld-thread", database_options);
    if(!mysqldResource.isRunning()) {
      throw new RuntimeException("MySQL did not start successfully!");
    }
    log.info("MySQL is running.");
    resource = mysqldResource;
  }
View Full Code Here

TOP

Related Classes of com.mysql.management.MysqldResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.