编写lineToObject方法
public PersonBean lineToObject(ResultSet resultSet) {
//获取零散数据
int id = 0;
String name = null;
String sex = null;
int age = 0;
String rank = null;
String department = null;
try {
id = resultSet.getInt(“id”);
name = resultSet.getString(“name”);
sex = resultSet.getString(“sex”);
age = resultSet.getInt(“age”);
rank = resultSet.getString(“rank”);
department = resultSet.getString(“department”);
} catch (SQLException throwables) {
throwables.printStackTrace();
}
//实例化一个bean对象
PersonBean personBean = new PersonBean();
//给对象赋值零散数据
personBean.setId(id);
personBean.setName(name);
personBean.setSex(sex);
personBean.setAge(age);
personBean.setSex(rank);
personBean.setDepartment(department);
//返回
return personBean;
}
报错的地方使用alt加enter甩锅或者ctrl加alt加t cry catch一下