📄 objtores.java
字号:
package sfs.connection;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import org.apache.commons.beanutils.BeanUtils;
import sfs.entity.Score;
import sfs.entity.Student;
import sfs.entity.Teacher;
public class ObjToRes{
private Object object;
public ObjToRes(String table,Object obj) throws SQLException, IllegalAccessException, InvocationTargetException, NoSuchMethodException{
if (table=="user_teacher"){
object=(Teacher)obj;
}
if (table=="user_student"){
object=(Student)obj;
}
if (table=="st_score"){
object=(Score)obj;
}
}
//取得int类型字段
public int getInt(String name) throws NumberFormatException, IllegalAccessException, InvocationTargetException, NoSuchMethodException{
int temp=0;
temp=Integer.parseInt(BeanUtils.getProperty(object,name));
return temp;
}
//取得String类型字段
public String getString(String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException{
String temp;
temp=BeanUtils.getProperty(object,name);
return temp;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -