All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.itsallcode.jdbc.ArgumentPreparedStatementSetter Maven / Gradle / Ivy

There is a newer version: 0.7.1
Show newest version
package org.itsallcode.jdbc;

import java.sql.PreparedStatement;
import java.sql.SQLException;

class ArgumentPreparedStatementSetter implements PreparedStatementSetter {
    private final Object[] args;
    private final ParameterMapper mapper;

    ArgumentPreparedStatementSetter(final ParameterMapper mapper, final Object[] args) {
        this.mapper = mapper;
        this.args = args;
    }

    public void setValues(final PreparedStatement preparedStatement) throws SQLException {
        int parameterIndex = 1;
        for (final Object arg : args) {
            preparedStatement.setObject(parameterIndex, mapper.map(arg));
            parameterIndex++;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy