Search in sources :

Example 1 with SqlStatement

use of io.vertigo.database.sql.statement.SqlStatement in project vertigo by KleeGroup.

the class AbstractTaskEngineSQL method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    final SqlConnection connection = obtainConnection();
    final SqlStatementBuilder statementBuilder = SqlStatement.builder(getSqlQuery().trim());
    setNamedParameters(statementBuilder);
    final SqlStatement sqlStatement = statementBuilder.build();
    try {
        // Execute le Statement JDBC.
        final OptionalInt sqlRowcountOpt = doExecute(sqlStatement, connection);
        // On positionne le nombre de lignes affectées.
        sqlRowcountOpt.ifPresent(this::setRowCount);
    } catch (final BatchUpdateException sqle) {
        // Gère les erreurs d'exécution Batch JDBC.
        throw handleSQLException(connection, sqle.getNextException(), sqlStatement.getSqlQuery());
    } catch (final SQLException sqle) {
        // Gère les erreurs d'exécution JDBC.
        throw handleSQLException(connection, sqle, sqlStatement.getSqlQuery());
    }
}
Also used : SqlStatement(io.vertigo.database.sql.statement.SqlStatement) SqlStatementBuilder(io.vertigo.database.sql.statement.SqlStatementBuilder) SQLException(java.sql.SQLException) SqlConnection(io.vertigo.database.sql.connection.SqlConnection) OptionalInt(java.util.OptionalInt) BatchUpdateException(java.sql.BatchUpdateException)

Aggregations

SqlConnection (io.vertigo.database.sql.connection.SqlConnection)1 SqlStatement (io.vertigo.database.sql.statement.SqlStatement)1 SqlStatementBuilder (io.vertigo.database.sql.statement.SqlStatementBuilder)1 BatchUpdateException (java.sql.BatchUpdateException)1 SQLException (java.sql.SQLException)1 OptionalInt (java.util.OptionalInt)1