Examples of HikariConfig


Examples of com.zaxxer.hikari.HikariConfig

                    ':' +
                    dbUri.getPort() +
                    dbUri.getPath() +
                    "?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory";

            HikariConfig config = new HikariConfig();
            config.setDataSourceClassName(propertyResolver.getProperty("dataSourceClassName"));
            config.addDataSourceProperty("url", dbUrl);
            config.addDataSourceProperty("user", username);
            config.addDataSourceProperty("password", password);
            return new HikariDataSource(config);
        } else {
            throw new ApplicationContextException("Heroku database URL is not configured, you must set --spring.datasource.heroku-url=$DATABASE_URL");
        }
    }
View Full Code Here

Examples of com.zaxxer.hikari.HikariConfig

      return createDataSource(properties);
   }

   public static DataSource createDataSource(Properties properties) throws Exception
   {
      HikariConfig config = new HikariConfig(properties);

      return new HikariDataSource(config);
   }
View Full Code Here

Examples of com.zaxxer.hikari.HikariConfig

         if (propValue == null) {
            propValue = properties.get(key);
         }

         if (target instanceof HikariConfig && propName.startsWith("dataSource.")) {
            HikariConfig config = (HikariConfig) target;
            config.addDataSourceProperty(propName.substring("dataSource.".length()), propValue);
         }
         else {
            setProperty(target, propName, propValue);
         }
      }
View Full Code Here

Examples of com.zaxxer.hikari.HikariConfig

         if (key.startsWith(CONFIG_PREFIX)) {
            hikariProps.setProperty(key.substring(CONFIG_PREFIX.length()), (String) props.get(key));
         }
      }

      return new HikariConfig(hikariProps);
   }
View Full Code Here

Examples of com.zaxxer.hikari.HikariConfig

                    "cannot start. Please check your Spring profile, current profiles are: {}",
                    Arrays.toString(environment.getActiveProfiles()));

            throw new ApplicationContextException("Database connection pool is not configured correctly");
        }
        HikariConfig config = new HikariConfig();
        config.setDataSourceClassName(propertyResolver.getProperty("dataSourceClassName"));
        if (propertyResolver.getProperty("url") == null || "".equals(propertyResolver.getProperty("url"))) {
            config.addDataSourceProperty("databaseName", propertyResolver.getProperty("databaseName"));
            config.addDataSourceProperty("serverName", propertyResolver.getProperty("serverName"));
        } else {
            config.addDataSourceProperty("url", propertyResolver.getProperty("url"));
        }
        config.addDataSourceProperty("user", propertyResolver.getProperty("username"));
        config.addDataSourceProperty("password", propertyResolver.getProperty("password"));

        //MySQL optimizations, see https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
        if ("com.mysql.jdbc.jdbc2.optional.MysqlDataSource".equals(propertyResolver.getProperty("dataSourceClassName"))) {
            config.addDataSourceProperty("cachePrepStmts", propertyResolver.getProperty("cachePrepStmts", "true"));
            config.addDataSourceProperty("prepStmtCacheSize", propertyResolver.getProperty("prepStmtCacheSize", "250"));
            config.addDataSourceProperty("prepStmtCacheSqlLimit", propertyResolver.getProperty("prepStmtCacheSqlLimit", "2048"));
            config.addDataSourceProperty("useServerPrepStmts", propertyResolver.getProperty("useServerPrepStmts", "true"));
        }
        return new HikariDataSource(config);
    }
View Full Code Here

Examples of com.zaxxer.hikari.HikariConfig

      if ( key.startsWith( CONFIG_PREFIX ) ) {
        hikariProps.setProperty( key.substring( CONFIG_PREFIX.length() ), (String) props.get( key ) );
      }
    }

    return new HikariConfig( hikariProps );
  }
View Full Code Here

Examples of com.zaxxer.hikari.HikariConfig

    public static DataSource getHikariDataSource(String driverClass,
                                                 String url,
                                                 String username,
                                                 String passwd,
                                                 Properties props) {
        HikariConfig config = new HikariConfig();

        config.setDriverClassName(driverClass);
        config.setJdbcUrl(url);
        config.setUsername(username);
        config.setPassword(passwd);

        // MySQL 인 경우 성능을 위해 아래 설정을 사용합니다.
        if (DataConst.DRIVER_CLASS_MYSQL.equals(driverClass)) {
            config.addDataSourceProperty("cachePrepStmts", "true");
            config.addDataSourceProperty("prepStmtCacheSize", "250");
            config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
            config.addDataSourceProperty("useServerPrepStmts", "true");
        }

        if (props != null) {
            for (Map.Entry<Object, Object> entry : props.entrySet())
                config.addDataSourceProperty(entry.getKey().toString(), entry.getValue().toString());
        }

        config.setInitializationFailFast(true);
        config.setConnectionTestQuery("SELECT 1");

        return new HikariDataSource(config);
    }
View Full Code Here

Examples of com.zaxxer.hikari.HikariConfig

    }

    @Bean
    public DataSource dataSource() {

        HikariConfig config = new HikariConfig();

        config.setDriverClassName("org.h2.Driver");
        config.setJdbcUrl("jdbc:h2:mem:test;MVCC=true;");
        config.setUsername("sa");
        config.setPassword("");

        config.setInitializationFailFast(true);
        config.setConnectionTestQuery("SELECT 1");

        return new HikariDataSource(config);

//        return new EmbeddedDatabaseBuilder()
//                .setType(EmbeddedDatabaseType.H2)
View Full Code Here

Examples of com.zaxxer.hikari.HikariConfig

  /**
   * Provides the DataSource used by this database. Override this method
   * to change how the DataSource is created or configured.
   */
  protected DataSource getDataSource() throws SQLException {
    HikariConfig config = new HikariConfig();
    config.setMaximumPoolSize(100);
    config.setDataSourceClassName(System.getProperty("norm.dataSourceClassName"));
    config.addDataSourceProperty("serverName", System.getProperty("norm.serverName"));
    config.addDataSourceProperty("databaseName", System.getProperty("norm.databaseName"));
    config.addDataSourceProperty("user", System.getProperty("norm.user"));
    config.addDataSourceProperty("password", System.getProperty("norm.password"));
    config.setInitializationFailFast(true);
    return new HikariDataSource(config);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.