帮我加一下注解
public static List getList(Class clazz, String sql) {
//null 空引用,只声明了 是List
List list = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = getConnection();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
int columnCount = metaData.getColumnCount();
Object obj = null;
list = new ArrayList();
while(rs.next()) {
obj = clazz.newInstance();
for(int i = 1; i <= columnCount; i ++) {
BeanUtils.copyProperty(obj, metaData.getColumnName(i), rs.getObject(i));
}
list.add(obj);
}
} catch (SQLException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} finally {
close(rs, pstmt, conn);
}
return list;
}