Here you can find the source of resultSetParseVO(ResultSet rs, Class> cls)
Parameter | Description |
---|---|
rs | a parameter |
cls | a parameter |
Parameter | Description |
---|---|
Exception | an exception |
public static Object resultSetParseVO(ResultSet rs, Class<?> cls) throws Exception
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; import java.sql.ResultSet; public class Main { /**//from w w w. j a v a2 s . c o m * * @param rs * @param cls * @return * @throws Exception */ public static Object resultSetParseVO(ResultSet rs, Class<?> cls) throws Exception { Object obj = cls.newInstance(); Field[] fs = cls.getDeclaredFields(); for (Field field : fs) { String name = field.getName(); String value = rs.getString(rs.findColumn(name)); field.set(obj, value); } return obj; } }