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();
}
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);
}
Aggregations