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

liquibase.executor.jvm.ArgPreparedStatementSetter Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package liquibase.executor.jvm;

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

/**
 * Simple adapter for PreparedStatementSetter that applies
 * a given array of arguments.
 *
 * @author Spring Framework
 */
class ArgPreparedStatementSetter implements PreparedStatementSetter {

    private final Object[] args;


    /**
     * Create a new ArgPreparedStatementSetter for the given arguments.
     *
     * @param args the arguments to set
     */
    public ArgPreparedStatementSetter(Object[] args) {
        this.args = args;
    }


    @Override
    public void setValues(PreparedStatement ps) throws SQLException {
        if (this.args != null) {
            for (int i = 0; i < this.args.length; i++) {
                Object arg = this.args[i];
                if (arg instanceof SqlParameterValue) {
                    SqlParameterValue paramValue = (SqlParameterValue) arg;
                    StatementCreatorUtils.setParameterValue(ps, i + 1, paramValue, paramValue.getValue());
                } else {
                    StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, arg);
                }
            }
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy