
org.eweb4j.orm.jdbc.RowMapping Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eweb4j-all Show documentation
Show all versions of eweb4j-all Show documentation
easy web framework for java, full-stack
The newest version!
package org.eweb4j.orm.jdbc;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eweb4j.util.CommonUtil;
/**
* 将从数据库查询出来的结果集映射成java对象
*
* @author cfuture.aw
* @since v1.a.0
*/
@SuppressWarnings("all")
public class RowMapping {
public static void main(String[] args){
System.out.println(Byte.class.getName());
}
public static T mapOneRow(ResultSet rs, Class cls) throws Exception {
List list = mapRows(rs, cls);
return list == null ? null : list.get(0);
}
public static List mapRows(ResultSet rs, Class cls) throws Exception {
if (rs == null)
return null;
ResultSetMetaData rsmd = rs.getMetaData();
List columns = new ArrayList();
for (int i = 1; i <= rsmd.getColumnCount(); ++i) {
columns.add(rsmd.getColumnLabel(i));
}
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy