liquibase.executor.jvm.ArgPreparedStatementSetter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-core Show documentation
Show all versions of liquibase-core Show documentation
Liquibase is a tool for managing and executing database changes.
The 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);
}
}
}
}
}