spring jdbctemplate调用procedure(返回游标)
2024-08-29 14:15:18
package cn.com.git.htsc.uac.core.repository.report; import cn.com.git.htsc.uac.core.api.dto.report.ReportCampaignDayOutDTO;
import oracle.jdbc.OracleTypes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcCall;
import org.springframework.stereotype.Repository; import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map; /**
* Created by wangyang on 2016/10/28.
*/
@Repository
public class ReportCampaignTotalRepository {
@Autowired
private JdbcTemplate primaryJdbcTemplate; public List<ReportCampaignDayOutDTO> getCampaignTotal(String start_date,String end_date,String campId,String deptId,String statu){
SimpleJdbcCall jdbcCall = new SimpleJdbcCall(primaryJdbcTemplate).withProcedureName("pro_credit_total").declareParameters(
new SqlOutParameter("results_out", OracleTypes.CURSOR, new QueryExchangeOrderDTOTypeMapper())
);
MapSqlParameterSource mapSqlParameterSource = new MapSqlParameterSource();
mapSqlParameterSource.addValue("startd", start_date);
mapSqlParameterSource.addValue("endd", end_date);
mapSqlParameterSource.addValue("actiid", campId);
mapSqlParameterSource.addValue("deptid", deptId);
mapSqlParameterSource.addValue("stat", statu);
Map<String, Object> results = jdbcCall.execute(mapSqlParameterSource);
List<ReportCampaignDayOutDTO> results_out = (List<ReportCampaignDayOutDTO>) results.get("results_out");
return results_out;
} private class QueryExchangeOrderDTOTypeMapper implements RowMapper {
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
ReportCampaignDayOutDTO dayOutDTO=new ReportCampaignDayOutDTO();
dayOutDTO.setCampaignId(rs.getString("campaign_id"));
dayOutDTO.setDayJoinPersonNum(rs.getLong("day_join_person_num"));
dayOutDTO.setDayJoinCountNum(rs.getLong("day_join_count_num"));
dayOutDTO.setDayCreditEarnNum(rs.getLong("day_credit_earn_num"));
dayOutDTO.setDayCreditExpendNum(rs.getLong("day_credit_expend_num"));
return dayOutDTO;
}
}
}
最新文章
- stl之截取:以一段字符串截取字符串
- placeholder的兼容性探索之路
- css读书笔记1:HTML标记和文档结构
- 两种获取connectionString的方式
- 如何在安裝SELinux的环境执行Quartus II
- Moving a Subversion Repository to Another Server
- POJ 2948 DP
- 避免VMware P2V 过程中遇到的磁盘问题及解决 版本5.5
- 树莓派linux系统中显示隐藏文件的几种方法
- iPhone照片格式heic图片怎么打开
- wap2app(九)-- 使用mui.previewImage之后,页面a链接不能跳转
- 安卓开发笔记——个性化TextView(新浪微博)
- 如何修改帝国cms文章点击量默认值和成倍增加
- JS导入导出Excel表格的方法
- centos Cannot allocate memory for the buffer pool
- Docker for Windows(一)下载与安装
- Linux下vim 快捷键
- rar安装和使用
- MySQL数据库错误号:2003 - Can&#39;t connect to MYSQL server on &#39;localhost&#39;(10061)
- Linux - 归档和压缩
热门文章
- Resharper中注释代码的快捷键
- zoj 3088 Easter Holidays(最长路+最短路+打印路径)
- 用cmd改计算机名.bat 无需重启电脑生效
- ACM1228_STL的应用
- 《University Calculus》-chape8-无穷序列和无穷级数-基本极限恒等式
- 解放程序猿宝贵的右手(或者是左手) ——Android自动化测试技巧
- Pipe - POJ 1039(线段相交交点)
- 每天一道算法_6_I Think I Need a Houseboat
- php中传值与传引用的区别。什么时候传值什么时候传引用?
- The app references non-public selectors in Payload