本文整理汇总了Java中org.apache.commons.dbutils.BasicRowProcessor类的典型用法代码示例。如果您正苦于以下问题:Java BasicRowProcessor类的具体用法?Java BasicRowProcessor怎么用?Java BasicRowProcessor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicRowProcessor类属于org.apache.commons.dbutils包,在下文中一共展示了BasicRowProcessor类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateProperDbUtilsVersion
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
private void validateProperDbUtilsVersion() {
Package dbutilsPackage = BasicRowProcessor.class.getPackage();
String dbutilsVersion = dbutilsPackage.getSpecificationVersion();
if (dbutilsVersion == null) {
return; // in case the jar is shaded, this information may not be available; hence, we are forced to return
}
String[] versionParts = dbutilsVersion.split("\\.");
if (versionParts.length < 2) {
throw new IllegalArgumentException("Improper dbutils version; must have at least two parts x.y; " + dbutilsVersion);
}
int majorVersion = Integer.valueOf(versionParts[0]).intValue();
int minorVersion = Integer.valueOf(versionParts[1]).intValue();
if (!(majorVersion >= 1 && minorVersion >= 6)) {
throw new IllegalArgumentException("commons-dbutils:commons-dbutils version must be >= 1.6 to avoid bugs w/ JDBC getColumnName() usage in <= 1.5");
}
}
示例2: queryEntity
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
@Override
public <T> T queryEntity(Class<T> entityClass, String sql, Object... params) {
T result;
try {
Map<String, String> columnMap = EntityHelper.getColumnMap(entityClass);
if (MapUtils.isNotEmpty(columnMap)) {
result = queryRunner.query(sql, new BeanHandler<T>(entityClass, new BasicRowProcessor(new BeanProcessor(columnMap))), params);
} else {
result = queryRunner.query(sql, new BeanHandler<T>(entityClass), params);
}
} catch (SQLException e) {
logger.error("查询出错!", e);
throw new RuntimeException(e);
}
printSQL(sql);
return result;
}
示例3: queryEntityList
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
@Override
public <T> List<T> queryEntityList(Class<T> entityClass, String sql, Object... params) {
List<T> result;
try {
Map<String, String> columnMap = EntityHelper.getColumnMap(entityClass);
if (MapUtils.isNotEmpty(columnMap)) {
result = queryRunner.query(sql, new BeanListHandler<T>(entityClass, new BasicRowProcessor(new BeanProcessor(columnMap))), params);
} else {
result = queryRunner.query(sql, new BeanListHandler<T>(entityClass), params);
}
} catch (SQLException e) {
logger.error("查询出错!", e);
throw new RuntimeException(e);
}
printSQL(sql);
return result;
}
示例4: queryEntity
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
@Override
public <T> T queryEntity(Class<T> entityClass, String sql, Object... params) {
T result;
try {
Map<String, String> columnMap = EntityHelper.getColumnMap(entityClass);
if (MapUtil.isNotEmpty(columnMap)) {
result = queryRunner.query(sql, new BeanHandler<>(entityClass, new BasicRowProcessor(new BeanProcessor(columnMap))), params);
} else {
result = queryRunner.query(sql, new BeanHandler<>(entityClass), params);
}
} catch (SQLException e) {
logger.error("查询出错!", e);
throw new RuntimeException(e);
}
printSQL(sql);
return result;
}
示例5: queryEntityList
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
@Override
public <T> List<T> queryEntityList(Class<T> entityClass, String sql, Object... params) {
List<T> result;
try {
Map<String, String> columnMap = EntityHelper.getColumnMap(entityClass);
if (MapUtil.isNotEmpty(columnMap)) {
result = queryRunner.query(sql, new BeanListHandler<T>(entityClass, new BasicRowProcessor(new BeanProcessor(columnMap))), params);
} else {
result = queryRunner.query(sql, new BeanListHandler<T>(entityClass), params);
}
} catch (SQLException e) {
logger.error("查询出错!", e);
throw new RuntimeException(e);
}
printSQL(sql);
return result;
}
示例6: queryBean
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
public static <T> T queryBean(QueryRunner runner, Class<T> cls, Map<String, String> map, String sql, Object... params) {
T result;
try {
if (MapUtil.isNotEmpty(map)) {
result = runner.query(sql, new BeanHandler<T>(cls, new BasicRowProcessor(new BeanProcessor(map))), params);
} else {
result = runner.query(sql, new BeanHandler<T>(cls), params);
}
printSQL(sql);
} catch (SQLException e) {
logger.error("查询出错!", e);
throw new RuntimeException(e);
}
return result;
}
示例7: queryBeanList
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
public static <T> List<T> queryBeanList(QueryRunner runner, Class<T> cls, Map<String, String> map, String sql, Object... params) {
List<T> result;
try {
if (MapUtil.isNotEmpty(map)) {
result = runner.query(sql, new BeanListHandler<T>(cls, new BasicRowProcessor(new BeanProcessor(map))), params);
} else {
result = runner.query(sql, new BeanListHandler<T>(cls), params);
}
printSQL(sql);
} catch (SQLException e) {
logger.error("查询出错!", e);
throw new RuntimeException(e);
}
return result;
}
示例8: getRowProcessor
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
public static synchronized RowProcessor getRowProcessor(Class<?> modelCls, ModelMeta modelMeta) {
if(ROW_PROCESSOR_MAP.containsKey(modelCls)) {
return ROW_PROCESSOR_MAP.get(modelCls);
}
RowProcessor rowProcessor = new BasicRowProcessor(new JdbcOrmBeanProcessor(modelCls, modelMeta));
ROW_PROCESSOR_MAP.put(modelCls, rowProcessor);
return rowProcessor;
}
示例9: resultSetToMaps
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
public static List<Map> resultSetToMaps(ResultSet rs) throws SQLException{
List<Map> results =new ArrayList<>();
BasicRowProcessor brp = new BasicRowProcessor();
while(rs.next()){
results.add(brp.toMap(rs));
}
return results;
}
示例10: resultSetToArrays
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
public static List<Object[]> resultSetToArrays(ResultSet rs) throws SQLException {
List<Object[]> results =new ArrayList<>();
BasicRowProcessor brp = new BasicRowProcessor();
while (rs.next()){
results.add(brp.toArray(rs));
}
return results;
}
示例11: netProcessor
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
public static RowProcessor netProcessor(Object... netConfig) {
getCurrentExplainers().add(new EntityNetSqlExplainer(netConfig));
return new BasicRowProcessor();
}
示例12: ResultSetIterator
import org.apache.commons.dbutils.BasicRowProcessor; //导入依赖的package包/类
/**
* Constructor for ResultSetIterator.
* @param rs Wrap this <code>ResultSet</code> in an <code>Iterator</code>.
*/
public ResultSetIterator(ResultSet rs) {
this(rs , new BasicRowProcessor());
}