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

org.fluentjdbc.Inserter Maven / Gradle / Ivy

There is a newer version: 0.5.3
Show newest version
package org.fluentjdbc;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

public class Inserter extends DatabaseStatement {

    private final PreparedStatement statement;
    private final List fields;

    Inserter(PreparedStatement statement, List fields) {
        this.statement = statement;
        this.fields = fields;
    }

    public void setField(String fieldName, Object value) throws SQLException {
        int position = fields.indexOf(fieldName);
        if (position < 0) {
            throw new IllegalArgumentException("Unknown field " + fieldName);
        }
        bindParameter(statement, position+1, value);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy