读书人

jdbcTemplate 调用存储过程跟回到函数

发布时间: 2013-10-25 14:36:53 作者: rapoo

jdbcTemplate 调用存储过程和回到函数

?2、jdbcTemplate查询数据 三种callback

1)org.springframework.jdbc.core.ResultSetExtractor:基本上属于JdbcTemplate内部使用的Callback接口,相对于下面两个Callback接口来说,ResultSetExtractor拥有更多的控制权,因为使用它,需要自行处理ResultSet。

public interface RowMapper {     Object mapRow(ResultSet rs, int rowNum) throws SQLException; } List customerList = jdbcTemplate.query("select * from customer", new RowMapper(){    public Object mapRow(ResultSet rs, int rowNumber) throws SQLException {       Customer customer = new Customer();       customer.setFirstName(rs.getString(1));       customer.setLastName(rs.getString(2));       ...       return customer;    }});

?

?

?

?

?

读书人网 >其他数据库

热点推荐