Search in sources :

Example 16 with PreparedStatementWrapper

use of uk.gov.justice.services.jdbc.persistence.PreparedStatementWrapper in project microservice_framework by CJSCommonPlatform.

the class EventStreamJdbcRepository method insert.

public void insert(final UUID streamId, final boolean active) {
    if (!isExistingStream(streamId)) {
        try (final PreparedStatementWrapper ps = eventStreamJdbcRepositoryHelper.preparedStatementWrapperOf(dataSource, SQL_INSERT_EVENT_STREAM)) {
            ps.setObject(1, streamId);
            ps.setTimestamp(2, toSqlTimestamp(clock.now()));
            ps.setBoolean(3, active);
            ps.executeUpdate();
        } catch (SQLException e) {
            throw new JdbcRepositoryException(format("Exception while storing stream %s", streamId), e);
        }
    }
}
Also used : SQLException(java.sql.SQLException) PreparedStatementWrapper(uk.gov.justice.services.jdbc.persistence.PreparedStatementWrapper) JdbcRepositoryException(uk.gov.justice.services.jdbc.persistence.JdbcRepositoryException)

Aggregations

SQLException (java.sql.SQLException)16 JdbcRepositoryException (uk.gov.justice.services.jdbc.persistence.JdbcRepositoryException)16 PreparedStatementWrapper (uk.gov.justice.services.jdbc.persistence.PreparedStatementWrapper)16 ResultSet (java.sql.ResultSet)2 InvalidStreamIdException (uk.gov.justice.services.eventsourcing.repository.jdbc.exception.InvalidStreamIdException)1