Search in sources :

Example 1 with SqlDataBaseManager

use of io.vertigo.database.sql.SqlDataBaseManager in project vertigo by KleeGroup.

the class SqlConnectionProviderPlugin method checkTestSelect.

@HealthChecked(name = "testQuery", feature = "sqlDatabase")
default HealthMeasure checkTestSelect() {
    final HealthMeasureBuilder healthMeasureBuilder = HealthMeasure.builder();
    final String testQuery = getDataBase().getSqlDialect().getTestQuery();
    try {
        final SqlDataBaseManager sqlDataBaseManager = Home.getApp().getComponentSpace().resolve(SqlDataBaseManager.class);
        final SqlConnection connection = obtainConnection();
        try {
            sqlDataBaseManager.executeQuery(SqlStatement.builder(testQuery).build(), Integer.class, 1, connection);
        } finally {
            connection.release();
        }
        healthMeasureBuilder.withGreenStatus();
    } catch (final Exception e) {
        healthMeasureBuilder.withRedStatus(e.getMessage(), e);
    }
    return healthMeasureBuilder.build();
}
Also used : HealthMeasureBuilder(io.vertigo.commons.analytics.health.HealthMeasureBuilder) SqlDataBaseManager(io.vertigo.database.sql.SqlDataBaseManager) SqlConnection(io.vertigo.database.sql.connection.SqlConnection) HealthChecked(io.vertigo.commons.analytics.health.HealthChecked)

Example 2 with SqlDataBaseManager

use of io.vertigo.database.sql.SqlDataBaseManager in project vertigo by KleeGroup.

the class NameSpace2JavaTest method execSqlScript.

private void execSqlScript(final String sqlScript, final App app) {
    final ResourceManager resourceManager = app.getComponentSpace().resolve(ResourceManager.class);
    final SqlDataBaseManager sqlDataBaseManager = app.getComponentSpace().resolve(SqlDataBaseManager.class);
    final SqlConnection connection = sqlDataBaseManager.getConnectionProvider(SqlDataBaseManager.MAIN_CONNECTION_PROVIDER_NAME).obtainConnection();
    DataBaseScriptUtil.execSqlScript(connection, sqlScript, resourceManager, sqlDataBaseManager);
}
Also used : SqlDataBaseManager(io.vertigo.database.sql.SqlDataBaseManager) SqlConnection(io.vertigo.database.sql.connection.SqlConnection) ResourceManager(io.vertigo.core.resource.ResourceManager)

Aggregations

SqlDataBaseManager (io.vertigo.database.sql.SqlDataBaseManager)2 SqlConnection (io.vertigo.database.sql.connection.SqlConnection)2 HealthChecked (io.vertigo.commons.analytics.health.HealthChecked)1 HealthMeasureBuilder (io.vertigo.commons.analytics.health.HealthMeasureBuilder)1 ResourceManager (io.vertigo.core.resource.ResourceManager)1