标签:
package db.mapping; import java.sql.ResultSet; import java.sql.SQLException; import org.springframework.jdbc.core.RowMapper; import db.bean.Employee; public class EmployeeMapper implements RowMapper { @Override public Object mapRow(ResultSet rs, int arg1) throws SQLException { // TODO Auto-generated method stub Employee emp = new Employee(); emp.setId(rs.getInt(1)); emp.setName(rs.getString(2)); emp.setDept_id(rs.getInt(3)); return emp; } }
spring对JDBC整合的时候,要注意自己写一个映射,继承RowMapper,查询的时候会用到,将返回的ResultSet一条对应一个Employee对象。
标签:
原文地址:http://www.cnblogs.com/hzzhero/p/5156042.html