Java Code Examples for io.vertx.pgclient.PgConnectOptions#setPort()
The following examples show how to use
io.vertx.pgclient.PgConnectOptions#setPort() .
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 File: PostgresClient.java From raml-module-builder with Apache License 2.0 | 5 votes |
static PgConnectOptions createPgConnectOptions(JsonObject sqlConfig) { PgConnectOptions pgConnectOptions = new PgConnectOptions(); String host = sqlConfig.getString(HOST); if (host != null) { pgConnectOptions.setHost(host); } Integer port = sqlConfig.getInteger(PORT); if (port != null) { pgConnectOptions.setPort(port); } String username = sqlConfig.getString(_USERNAME); if (username != null) { pgConnectOptions.setUser(username); } String password = sqlConfig.getString(_PASSWORD); if (password != null) { pgConnectOptions.setPassword(password); } String database = sqlConfig.getString(DATABASE); if (database != null) { pgConnectOptions.setDatabase(database); } Integer connectionReleaseDelay = sqlConfig.getInteger(CONNECTION_RELEASE_DELAY, DEFAULT_CONNECTION_RELEASE_DELAY); pgConnectOptions.setIdleTimeout(connectionReleaseDelay); pgConnectOptions.setIdleTimeoutUnit(TimeUnit.MILLISECONDS); return pgConnectOptions; }
Example 2
Source File: PostgresHandle.java From okapi with Apache License 2.0 | 4 votes |
PostgresHandle(Vertx vertx, JsonObject conf) { String val; connectOptions = new PgConnectOptions(); val = Config.getSysConf("postgres_host", null, conf); if (val != null) { connectOptions.setHost(val); } val = Config.getSysConf("postgres_port", null, conf); Logger logger = OkapiLogger.get(); if (val != null) { try { connectOptions.setPort(Integer.parseInt(val)); } catch (NumberFormatException e) { logger.warn("Bad postgres_port value: {}: {}", val, e.getMessage()); } } // postgres_user is supported for system configuration (-D option) only and is deprecated connectOptions.setUser(Config.getSysConf("postgres_username", Config.getSysConf("postgres_user", "okapi", new JsonObject()), conf)); connectOptions.setPassword(Config.getSysConf("postgres_password", "okapi25", conf)); connectOptions.setDatabase(Config.getSysConf("postgres_database", "okapi", conf)); String serverPem = Config.getSysConf("postgres_server_pem", null, conf); if (serverPem != null) { logger.debug("Enforcing SSL encryption for PostgreSQL connections, " + "requiring TLSv1.3 with server name certificate"); connectOptions.setSslMode(SslMode.VERIFY_FULL); connectOptions.setHostnameVerificationAlgorithm("HTTPS"); connectOptions.setPemTrustOptions( new PemTrustOptions().addCertValue(Buffer.buffer(serverPem))); connectOptions.setEnabledSecureTransportProtocols(Collections.singleton("TLSv1.3")); connectOptions.setOpenSslEngineOptions(new OpenSSLEngineOptions()); } PoolOptions poolOptions = new PoolOptions(); poolOptions.setMaxSize(5); pool = PgPool.pool(vertx, connectOptions, poolOptions); logger.debug("created"); }
Example 3
Source File: PgClientFactory.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 2 votes |
PgPool sqlClient(int size) { PoolOptions options = new PoolOptions(); PgConnectOptions connectOptions = new PgConnectOptions(); Matcher matcher = Pattern.compile(PG_URI_MATCHER).matcher(url); matcher.matches(); connectOptions.setDatabase(matcher.group(3)); connectOptions.setHost(matcher.group(1)); connectOptions.setPort(Integer.parseInt(matcher.group(2))); connectOptions.setUser(user); connectOptions.setPassword(pass); connectOptions.setCachePreparedStatements(true); options.setMaxSize(size); return PgPool.pool(vertx, connectOptions, options); }