com.bixuebihui.jdbc.RowMapperResultReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of c-dbtools Show documentation
Show all versions of c-dbtools Show documentation
a fast small database connection pool and a active record flavor mini framework
package com.bixuebihui.jdbc;
import jakarta.validation.constraints.NotNull;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* RowMapperResultReader class.
*
* @author xingwx
* @version $Id: $Id
*/
public class RowMapperResultReader {
private final RowMapper handle;
private List res;
/**
* Constructor for RowMapperResultReader.
*
* @param handle a {@link RowMapper} object.
*/
public RowMapperResultReader(RowMapper handle){
this.handle = handle;
}
/**
* Constructor for RowMapperResultReader.
*
* @param handle a {@link RowMapper} object.
* @param resultList a {@link java.util.List} object.
*/
public RowMapperResultReader(RowMapper handle, List resultList){
this.handle = handle;
this.res = resultList;
}
/**
* processResultSet.
*
* @param rs a {@link java.sql.ResultSet} object.
* @return a {@link java.util.List} object.
* @throws java.sql.SQLException if any.
*/
public @NotNull List processResultSet(ResultSet rs, Set fields) throws SQLException {
if(res==null){
res = new ArrayList<>();
}else{
res.clear();
}
int index=1;
while (rs.next()) {
res.add( handle.mapRow(rs, index++, fields));
}
return res;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy