io.vertx.mysqlclient.MySQLConnectOptions Java Examples
The following examples show how to use
io.vertx.mysqlclient.MySQLConnectOptions.
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: MySQLTest.java From vertx-auth with Apache License 2.0 | 6 votes |
@Before public void before() { // Create the client pool mysql = MySQLPool.pool( rule.vertx(), // default config new MySQLConnectOptions() .setPort(container.getMappedPort(3306)) .setHost(container.getContainerIpAddress()) .setDatabase("testschema") .setUser("mysql") .setPassword("password"), // default pool config new PoolOptions() .setMaxSize(5)); }
Example #2
Source File: MySQLPoolImpl.java From vertx-sql-client with Apache License 2.0 | 5 votes |
public static MySQLPoolImpl create(ContextInternal context, boolean closeVertx, MySQLConnectOptions connectOptions, PoolOptions poolOptions) { QueryTracer tracer = context.tracer() == null ? null : new QueryTracer(context.tracer(), connectOptions); VertxMetrics vertxMetrics = context.owner().metricsSPI(); ClientMetrics metrics = vertxMetrics != null ? vertxMetrics.createClientMetrics(connectOptions.getSocketAddress(), "sql", connectOptions.getMetricsName()) : null; MySQLPoolImpl pool = new MySQLPoolImpl(context, new MySQLConnectionFactory(context, connectOptions), tracer, metrics, poolOptions); CloseFuture closeFuture = pool.closeFuture(); if (closeVertx) { closeFuture.onComplete(ar -> context.owner().close()); } else { context.addCloseHook(closeFuture); } return pool; }
Example #3
Source File: MySQLRule.java From vertx-sql-client with Apache License 2.0 | 5 votes |
public synchronized MySQLConnectOptions startServer() throws Exception { initServer(); server.start(); return new MySQLConnectOptions() .setPort(server.getMappedPort(3306)) .setHost(server.getContainerIpAddress()) .setDatabase("testschema") .setUser("mysql") .setPassword("password"); }
Example #4
Source File: MySQLConnectionImpl.java From vertx-sql-client with Apache License 2.0 | 5 votes |
public static Future<MySQLConnection> connect(Vertx vertx, MySQLConnectOptions options) { ContextInternal ctx = (ContextInternal) vertx.getOrCreateContext(); MySQLConnectionFactory client; try { client = new MySQLConnectionFactory(ctx, options); } catch (Exception e) { return ctx.failedFuture(e); } QueryTracer tracer = ctx.tracer() == null ? null : new QueryTracer(ctx.tracer(), options); Promise<MySQLConnection> promise = ctx.promise(); ctx.dispatch(null, v -> connect(client, ctx, tracer, null, promise)); return promise.future(); }
Example #5
Source File: MySQLDriver.java From vertx-sql-client with Apache License 2.0 | 5 votes |
private static MySQLConnectOptions wrap(SqlConnectOptions options) { if (options instanceof MySQLConnectOptions) { return (MySQLConnectOptions) options; } else { return new MySQLConnectOptions(options); } }
Example #6
Source File: MySQLTest.java From vertx-sql-client with Apache License 2.0 | 5 votes |
public static MySQLConnectOptions connectOptions() { Integer port = server.getMappedPort(3306); String ip = server.getContainerIpAddress(); return new MySQLConnectOptions() .setPort(port) .setHost(ip) .setDatabase("testschema") .setUser("mysql") .setPassword("password"); }
Example #7
Source File: MySQLPoolRecorder.java From quarkus with Apache License 2.0 | 5 votes |
private MySQLPool legacyInitialize(Vertx vertx, DataSourceRuntimeConfig dataSourceRuntimeConfig, LegacyDataSourceRuntimeConfig legacyDataSourceRuntimeConfig, LegacyDataSourceReactiveMySQLConfig legacyDataSourceReactiveMySQLConfig) { PoolOptions poolOptions = legacyToPoolOptionsLegacy(legacyDataSourceRuntimeConfig); MySQLConnectOptions mysqlConnectOptions = legacyToMySQLConnectOptions(dataSourceRuntimeConfig, legacyDataSourceRuntimeConfig, legacyDataSourceReactiveMySQLConfig); return MySQLPool.pool(vertx, mysqlConnectOptions, poolOptions); }
Example #8
Source File: MySQLPoolRecorder.java From quarkus with Apache License 2.0 | 5 votes |
private MySQLPool initialize(Vertx vertx, DataSourceRuntimeConfig dataSourceRuntimeConfig, DataSourceReactiveRuntimeConfig dataSourceReactiveRuntimeConfig, DataSourceReactiveMySQLConfig dataSourceReactiveMySQLConfig) { PoolOptions poolOptions = toPoolOptions(dataSourceRuntimeConfig, dataSourceReactiveRuntimeConfig, dataSourceReactiveMySQLConfig); MySQLConnectOptions mysqlConnectOptions = toMySQLConnectOptions(dataSourceRuntimeConfig, dataSourceReactiveRuntimeConfig, dataSourceReactiveMySQLConfig); if (dataSourceReactiveRuntimeConfig.threadLocal.isPresent() && dataSourceReactiveRuntimeConfig.threadLocal.get()) { return new ThreadLocalMySQLPool(vertx, mysqlConnectOptions, poolOptions); } return MySQLPool.pool(vertx, mysqlConnectOptions, poolOptions); }
Example #9
Source File: MySQLDriver.java From vertx-sql-client with Apache License 2.0 | 4 votes |
@Override public boolean acceptsOptions(SqlConnectOptions options) { return options instanceof MySQLConnectOptions || SqlConnectOptions.class.equals(options.getClass()); }
Example #10
Source File: ThreadLocalMySQLPool.java From quarkus with Apache License 2.0 | 4 votes |
public ThreadLocalMySQLPool(Vertx vertx, MySQLConnectOptions mySQLConnectOptions, PoolOptions poolOptions) { super(vertx, poolOptions); this.mySQLConnectOptions = mySQLConnectOptions; }
Example #11
Source File: MySQLConnectionFactory.java From vertx-sql-client with Apache License 2.0 | 4 votes |
public MySQLConnectionFactory(ContextInternal context, MySQLConnectOptions options) { NetClientOptions netClientOptions = new NetClientOptions(options); this.context = context; this.host = options.getHost(); this.port = options.getPort(); this.username = options.getUser(); this.password = options.getPassword(); this.database = options.getDatabase(); this.connectionAttributes = options.getProperties() == null ? null : Collections.unmodifiableMap(options.getProperties()); MySQLCollation collation; if (options.getCollation() != null) { // override the collation if configured collation = MySQLCollation.valueOfName(options.getCollation()); charsetEncoding = Charset.forName(collation.mappedJavaCharsetName()); } else { String charset = options.getCharset(); if (charset == null) { collation = MySQLCollation.DEFAULT_COLLATION; } else { collation = MySQLCollation.valueOfName(MySQLCollation.getDefaultCollationFromCharsetName(charset)); } String characterEncoding = options.getCharacterEncoding(); if (characterEncoding == null) { charsetEncoding = Charset.defaultCharset(); } else { charsetEncoding = Charset.forName(options.getCharacterEncoding()); } } this.collation = collation; this.useAffectedRows = options.isUseAffectedRows(); this.sslMode = options.getSslMode(); // server RSA public key Buffer serverRsaPublicKey = null; if (options.getServerRsaPublicKeyValue() != null) { serverRsaPublicKey = options.getServerRsaPublicKeyValue(); } else { if (options.getServerRsaPublicKeyPath() != null) { serverRsaPublicKey = context.owner().fileSystem().readFileBlocking(options.getServerRsaPublicKeyPath()); } } this.serverRsaPublicKey = serverRsaPublicKey; this.initialCapabilitiesFlags = initCapabilitiesFlags(); // check the SSLMode here switch (sslMode) { case VERIFY_IDENTITY: String hostnameVerificationAlgorithm = netClientOptions.getHostnameVerificationAlgorithm(); if (hostnameVerificationAlgorithm == null || hostnameVerificationAlgorithm.isEmpty()) { throw new IllegalArgumentException("Host verification algorithm must be specified under VERIFY_IDENTITY ssl-mode."); } case VERIFY_CA: TrustOptions trustOptions = netClientOptions.getTrustOptions(); if (trustOptions == null) { throw new IllegalArgumentException("Trust options must be specified under " + sslMode.name() + " ssl-mode."); } break; } this.cachePreparedStatements = options.getCachePreparedStatements(); this.preparedStatementCacheSize = options.getPreparedStatementCacheMaxSize(); this.preparedStatementCacheSqlFilter = options.getPreparedStatementCacheSqlFilter(); this.netClient = context.owner().createNetClient(netClientOptions); }
Example #12
Source File: MySQLRule.java From vertx-sql-client with Apache License 2.0 | 4 votes |
public MySQLConnectOptions options() { return new MySQLConnectOptions(options); }
Example #13
Source File: MySQLRule.java From vertx-sql-client with Apache License 2.0 | 4 votes |
@Override protected void before() throws Throwable { // use an external database for testing if (isTestingWithExternalDatabase() && !ssl) { options = MySQLConnectOptions.fromUri(connectionUri); databaseServerInfo = DatabaseServerInfo.EXTERNAL; return; } // use an external database for tls testing if (isTlsTestingWithExternalDatabase() && ssl) { options = MySQLConnectOptions.fromUri(tlsConnectionUri); databaseServerInfo = DatabaseServerInfo.EXTERNAL; return; } // We do not need to launch another server if it's a shared instance if (this.server != null) { return; } // server type DatabaseType databaseType; String databaseTypeString = System.getProperty("testing.mysql.database.server"); if (isSystemPropertyValid(databaseTypeString)) { databaseType = parseDatabaseTypeString(databaseTypeString); } else { // MySQL by default databaseType = DatabaseType.MySQL; } // server version String databaseVersionString = System.getProperty("testing.mysql.database.version"); if (isSystemPropertyValid(databaseVersionString)) { this.databaseServerInfo = DatabaseServerInfo.valueOf(databaseType, databaseVersionString); } else { // use default version for testing servers if (databaseType == DatabaseType.MySQL) { // 5.7 by default for MySQL this.databaseServerInfo = DatabaseServerInfo.MySQL_V5_7; } else if (databaseType == DatabaseType.MariaDB) { // 10.4 by default for MariaDB this.databaseServerInfo = DatabaseServerInfo.MariaDB_V10_4; } else { throw new IllegalStateException("Unimplemented default version for: " + databaseType); } } options = startServer(); }
Example #14
Source File: MySQLDataTypeTestBase.java From vertx-sql-client with Apache License 2.0 | 4 votes |
@Before public void setup() { vertx = Vertx.vertx(); options = new MySQLConnectOptions(MySQLTestBase.options); }
Example #15
Source File: MySQLTransactionTest.java From vertx-sql-client with Apache License 2.0 | 4 votes |
@Override protected Pool createPool() { return MySQLPool.pool(vertx, new MySQLConnectOptions(rule.options()), new PoolOptions().setMaxSize(1)); }
Example #16
Source File: MySQLTransactionTest.java From vertx-sql-client with Apache License 2.0 | 4 votes |
@Override protected Pool nonTxPool() { return MySQLPool.pool(vertx, new MySQLConnectOptions(rule.options()), new PoolOptions().setMaxSize(1)); }
Example #17
Source File: MySQLClientConfiguration.java From micronaut-sql with Apache License 2.0 | 2 votes |
/** * * @return The options for configuring a connection. */ public MySQLConnectOptions getConnectOptions() { return connectOptions; }