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;
}
}