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

com.github.alittlehuang.data.jdbc.sql.BatchUpdatePrecompiledSql Maven / Gradle / Ivy

The newest version!
package com.github.alittlehuang.data.jdbc.sql;

import com.github.alittlehuang.data.jdbc.JdbcUtil;
import com.github.alittlehuang.data.log.Logger;
import com.github.alittlehuang.data.log.LoggerFactory;

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

/**
 * @author ALittleHuang
 */
public class BatchUpdatePrecompiledSql extends PrecompiledSql {
    private static Logger logger = LoggerFactory.getLogger(BatchUpdatePrecompiledSql.class);

    public BatchUpdatePrecompiledSql(String sql, List> args) {
        super(sql, args);
    }

    @Override
    public List> getArgs() {
        //noinspection unchecked
        return (List>) super.getArgs();
    }

    @Override
    public void logSql() {
        List> args = getArgs();
        String sql = getSql();
        for ( List arg : args ) {
            JdbcUtil.logSql(sql, arg);
        }
    }

    @Override
    public void setValues(PreparedStatement ps) throws SQLException {
        List> args = getArgs();
        for ( List arg : args ) {
            JdbcUtil.setParam(ps, arg);
            ps.addBatch();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy