Java Code Examples for

The following examples show how to use These examples are extracted from open source projects. 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 Project: MegaSparkDiff   Source File:    License: Apache License 2.0 6 votes vote down vote up
public static void startPostgres() throws IOException {
  IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()

  PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getInstance(runtimeConfig);

  PostgresConfig config = new PostgresConfig(
      () -> "9.6.3-1",
      new Net(),
      new Storage("src/test/resources/sample"),
      new Timeout(),
      new Credentials("username", "password"));

  PostgresExecutable exec = runtime.prepare(config);
  process = exec.start();

  properties.setProperty("user", config.credentials().username());
  properties.setProperty("password", config.credentials().password());

  url = java.lang.String.format("jdbc:postgresql://%s:%s/%s",,,;
Example 2
Source Project: raml-module-builder   Source File:    License: Apache License 2.0 6 votes vote down vote up
 * .sql files
 * @param path
public void importFileEmbedded(String path) {
  // starting Postgres
  if (embeddedMode) {
    if (embeddedPostgres != null) {
      Optional<PostgresProcess> optionalPostgresProcess = embeddedPostgres.getProcess();
      if (optionalPostgresProcess.isPresent()) {"embedded postgress import starting....");
        PostgresProcess postgresProcess = optionalPostgresProcess.get();
        postgresProcess.importFromFile(new File(path));"embedded postgress import complete....");
      } else {
        log.warn("embedded postgress is not running...");
    } else {"embedded postgress not enabled");
Example 3
Source Project: postgres-async-driver   Source File:    License: Apache License 2.0 5 votes vote down vote up
DatabaseRule(NettyConnectibleBuilder builder) {
    this.builder = builder;
    if (builder instanceof EmbeddedConnectionPoolBuilder) {
        String port = System.getProperty("asyncpg.test.postgres.port");
        if (port != null && !port.isBlank()) {
        } else {
            if (process == null) {
                try {
                    PostgresStarter<PostgresExecutable, PostgresProcess> runtime = PostgresStarter.getDefaultInstance();
                    PostgresConfig config = new PostgresConfig(Version.V11_1, new AbstractPostgresConfig.Net(),
                            new AbstractPostgresConfig.Storage("async-pg"), new AbstractPostgresConfig.Timeout(),
                            new AbstractPostgresConfig.Credentials("async-pg", "async-pg"));
                    PostgresExecutable exec = runtime.prepare(config);
                    process = exec.start();

                    System.out.printf("Started postgres to %s:%d%n", process.getConfig().net().host(), process.getConfig().net().port());
                } catch (IOException e) {
                    throw new RuntimeException(e);