use of io.jans.orm.sql.operation.impl.SqlConnectionProvider in project jans by JanssenProject.
the class SqlEntryManagerFactory method createEntryManager.
@Override
public SqlEntryManager createEntryManager(Properties conf) {
Properties entryManagerConf = PropertiesHelper.filterProperties(conf, "#");
SqlConnectionProvider connectionProvider = new SqlConnectionProvider(entryManagerConf);
connectionProvider.create();
if (!connectionProvider.isCreated()) {
throw new ConfigurationException(String.format("Failed to create SQL connection pool! Result code: '%s'", connectionProvider.getCreationResultCode()));
}
LOG.debug("Created connectionProvider '{}' with code '{}'", connectionProvider, connectionProvider.getCreationResultCode());
SqlEntryManager sqlEntryManager = new SqlEntryManager(new SqlOperationServiceImpl(entryManagerConf, connectionProvider));
LOG.info("Created SqlEntryManager: {}", sqlEntryManager.getOperationService());
return sqlEntryManager;
}
use of io.jans.orm.sql.operation.impl.SqlConnectionProvider in project jans by JanssenProject.
the class SqlConfigurationResource method test.
@POST
@Path(ApiConstants.TEST)
@ProtectedApi(scopes = { ApiAccessConstants.DATABASE_SQL_READ_ACCESS })
public Response test(@Valid @NotNull SqlConnectionConfiguration conf) {
log.debug("SQL to be tested - conf = " + conf);
Properties properties = new Properties();
properties.put("sql.db.schema.name", conf.getSchemaName());
properties.put("sql.connection.uri", Joiner.on(",").join(conf.getConnectionUri()));
properties.put("sql.connection.driver-property.serverTimezone", conf.getServerTimezone());
properties.put("sql.connection.pool.max-total", conf.getConnectionPoolMaxTotal());
properties.put("sql.connection.pool.max-idle", conf.getConnectionPoolMaxIdle());
properties.put("sql.auth.userName", conf.getUserName());
properties.put("sql.auth.userPassword", conf.getUserPassword());
// Password hash method
properties.put("sql.password.encryption.method", conf.getPasswordEncryptionMethod());
// Max time needed to create connection pool in milliseconds
properties.put("sql.connection.pool.create-max-wait-time-millis", conf.getCreateMaxWaitTimeMillis());
// Max wait 20 seconds
properties.put("sql.connection.pool.max-wait-time-millis", conf.getMaxWaitTimeMillis());
// Allow to evict connection in pool after 30 minutes
properties.put("sql.connection.pool.min-evictable-idle-time-millis", conf.getMinEvictableIdleTimeMillis());
properties.put("sql.binaryAttributes", Joiner.on(",").join(conf.getBinaryAttributes()));
properties.put("sql.certificateAttributes", Joiner.on(",").join(conf.getCertificateAttributes()));
SqlConnectionProvider connectionProvider = new SqlConnectionProvider(properties);
return Response.ok(connectionProvider.isConnected()).build();
}
Aggregations