public class ResultSetUtil extends Object
Constructor and Description |
---|
ResultSetUtil() |
Modifier and Type | Method and Description |
---|---|
static Object |
getColumnValue(ResultSet rs,
int columnIndex,
int type,
Type targetColumnType)
获取字段值
针对日期时间等做单独处理判断 |
static List<Object> |
handleRowToList(ResultSet rs)
处理单行数据
|
static <T> T |
toBean(ResultSetMetaData meta,
ResultSet rs,
Class<T> beanClass)
处理单条数据
|
static <E,T extends Collection<E>> |
toBeanList(ResultSet rs,
T collection,
Class<E> elementBeanType)
处理多条数据并返回一个Bean列表
|
static <T extends Collection<Entity>> |
toEntityList(ResultSet rs,
T collection)
处理多条数据
|
static <T extends Collection<Entity>> |
toEntityList(ResultSet rs,
T collection,
boolean caseInsensitive)
处理多条数据
|
static Long |
toLong(ResultSet rs)
结果集读取为一个Long值,一版用于插入时返回主键等
当有多个值返回时,只取第一个 |
public static <T> T toBean(ResultSetMetaData meta, ResultSet rs, Class<T> beanClass) throws SQLException
T
- Bean类型meta
- ResultSetMetaDatars
- 数据集beanClass
- 目标Bean类型SQLException
- SQL执行异常public static List<Object> handleRowToList(ResultSet rs) throws SQLException
rs
- 数据集(行)SQLException
- SQL执行异常public static <T extends Collection<Entity>> T toEntityList(ResultSet rs, T collection) throws SQLException
T
- 集合类型rs
- 数据集collection
- 数据集SQLException
- SQL执行异常public static <T extends Collection<Entity>> T toEntityList(ResultSet rs, T collection, boolean caseInsensitive) throws SQLException
T
- 集合类型rs
- 数据集collection
- 数据集caseInsensitive
- 是否大小写不敏感SQLException
- SQL执行异常public static <E,T extends Collection<E>> T toBeanList(ResultSet rs, T collection, Class<E> elementBeanType) throws SQLException
E
- 集合元素类型T
- 集合类型rs
- 数据集collection
- 数据集elementBeanType
- Bean类型SQLException
- SQL执行异常public static Long toLong(ResultSet rs) throws SQLException
rs
- 数据集SQLException
- SQL执行异常public static Object getColumnValue(ResultSet rs, int columnIndex, int type, Type targetColumnType) throws SQLException
rs
- ResultSet
columnIndex
- 字段索引,从1开始计数type
- 字段类型,默认ObjecttargetColumnType
- 结果要求的类型,需进行二次转换(null或者Object不转换)SQLException
- SQL异常Copyright © 2025. All rights reserved.