码迷,mamicode.com
首页 > 编程语言 > 详细

spring heibernate 调用存储过程

时间:2016-11-26 14:40:04      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:com   div   blog   res   gis   exe   aac   back   out   

一:参考网址

http://sunbin123.iteye.com/blog/1007556

二:示例

   @Autowired
    @Qualifier("jdbcTemplate")
    private JdbcTemplate jdbcTemplate;
  @SuppressWarnings("unchecked")
    public Integer GetSerNo() {   
          Integer param2Value =  jdbcTemplate.execute(   
             new CallableStatementCreator() {   
                public CallableStatement createCallableStatement(Connection con) throws SQLException {   
                   String storedProc = "{call getSNo(?,?)}";// 调用的sql   
                   CallableStatement cs = con.prepareCall(storedProc);   
                   cs.setString(1, sno);// 设置输入参数的值   
                   cs.registerOutParameter(2, java.sql.Types.INTEGER);
                   return cs;   
                }   
             }, new CallableStatementCallback() {   
                 public Object doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {   
                   cs.execute();   
                   return cs.getInt(2);// 获取输出参数的值   
             }   
          }); 
          return param2Value;
        }  
    

 

spring heibernate 调用存储过程

标签:com   div   blog   res   gis   exe   aac   back   out   

原文地址:http://www.cnblogs.com/fdzfd/p/6103983.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!