java通过newInstance生成对应实体类型
public static void main(String[] args) throws SQLException {DmCustomerExcellent dmCustomerExcellent = new DmCustomerExcellent();
Connection conn = getConnection();
Map<String, Class> map = new HashMap<>();
map.put("dm_customer_excellent", DmCustomerExcellent.class);
String sql = "select * from dm_customer_excellent where rownum = 1 ";
Class class1 = map.get("dm_customer_excellent");
try {
Object testCustomerExcellent = class1.newInstance();
if(testCustomerExcellent instanceof DmCustomerExcellent){
DmCustomerExcellent tt = (DmCustomerExcellent)testCustomerExcellent;
tt.setActperbusi2("-adfa-f--");
System.out.println(tt.getActperbusi2());
}
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
以上是 java通过newInstance生成对应实体类型 的全部内容, 来源链接: utcz.com/z/393086.html