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

com.alexkasko.springjdbc.parallel.NamedParameterJdbcTemplateFunction Maven / Gradle / Ivy

Go to download

Processes given SQL query in parallel in multiple data sources (assuming that all data source contain the same data). Combined results from multiple queries are exposed to application as java.util.Iterator. Worker thread use spring's JdbcTemplate with named parameters support.

There is a newer version: 1.2.3
Show newest version
package com.alexkasko.springjdbc.parallel;

import com.google.common.base.Function;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import javax.sql.DataSource;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Helper function, wraps {@link javax.sql.DataSource} into {@code NamedParameterJdbcTemplate}
 *
 * @author alexkasko
 * Date: 11/9/12
 */
class NamedParameterJdbcTemplateFunction implements Function {
    static final Function NPJT_FUNCTION = new NamedParameterJdbcTemplateFunction();

    /**
     * {@inheritDoc}
     */
    @Override
    public NamedParameterJdbcTemplate apply(DataSource input) {
        checkNotNull(input, "Provided data source is null");
        return new NamedParameterJdbcTemplate(input);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy