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

org.solovyev.common.db.ListProduceManager Maven / Gradle / Ivy

The newest version!
package org.solovyev.common.db;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * User: serso
 * Date: Oct 16, 2009
 * Time: 12:46:54 AM
 */
public class ListProduceManager extends AbstractProduceManager implements SQLCommand>{

    private List list;

    public ListProduceManager(SQLProducer tsqlProducer, List list) {
        super(tsqlProducer);
        this.list = list;
    }

    public ListProduceManager(SQLProducer tsqlProducer) {
        this(tsqlProducer, new ArrayList());
    }

    public List execute(Connection dbConnection) throws SQLException {
        Statement s = dbConnection.createStatement();
        ResultSet rs;
        rs = s.executeQuery(producer.getQuery().getStringQuery());
        if (rs != null ) {
            while (rs.next()) {
                list.add(producer.createInstance(rs, dbConnection));
            }
        }
        return list;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy