org.voovan.db.ResultInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of voovan-database Show documentation
Show all versions of voovan-database Show documentation
Voovan is a java framwork and it not depends on any third-party framework.
package org.voovan.db;
import org.voovan.tools.TSQL;
import org.voovan.tools.log.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 结果集和数据库连接封装
*
* @author helyho
*
* Java Framework.
* WebSite: https://github.com/helyho/Voovan
* Licence: Apache v2 License
*/
public class ResultInfo {
private ResultSet resultSet;
private JdbcOperate jdbcOperate;
public ResultInfo(ResultSet resultSet,JdbcOperate jdbcOperate) {
this.resultSet = resultSet;
this.jdbcOperate =jdbcOperate;
}
public JdbcOperate getJdbcOperate() {
return jdbcOperate;
}
@SuppressWarnings("unchecked")
public List getObjectList(Class t) {
try{
return (List) TSQL.getAllRowWithObjectList(t, this.resultSet);
}catch(SQLException | ReflectiveOperationException | ParseException e){
Logger.error("JdbcOperate.getObjectList error",e);
}finally{
// 非事务模式执行
if (jdbcOperate.getTranscationType() == TranscationType.NONE) {
jdbcOperate.closeConnection(resultSet);
}else{
jdbcOperate.closeResult(resultSet);
}
}
return new ArrayList();
}
public List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy