zoukankan      html  css  js  c++  java
  • jdbc Template 存储过程 返回多个结果 ,out 输出参数

    public ReportVo getReport() {
      //执行存储过程
    ReportVo reportVo=jdbcTemplate.execute(new CallableStatementCreator() {
    @Override
    public CallableStatement createCallableStatement(Connection connection) throws SQLException {
            //注意:这里会有坑, 有几个参数就写几个问号{CALL management_report(?,?,?,?,?,?)}

    String sql = "{CALL management_report(?,?,?,?,?,?)}";
                CallableStatement prepareCall = connection.prepareCall(sql);
    prepareCall.registerOutParameter(1, Types.INTEGER);
    prepareCall.registerOutParameter(2, Types.INTEGER);
    prepareCall.registerOutParameter(3, Types.DOUBLE);
    prepareCall.registerOutParameter(4, Types.DOUBLE);
    prepareCall.registerOutParameter(5, Types.INTEGER);
    prepareCall.registerOutParameter(6, Types.INTEGER);
    return prepareCall;
    }
    }, new CallableStatementCallback<ReportVo>() {
    @Override
    public ReportVo doInCallableStatement(CallableStatement callableStatement) throws SQLException, DataAccessException {
    callableStatement.execute();
    int partyGroupCount=callableStatement.getInt(1);
    int personCount=callableStatement.getInt(2);
    Double shipPlateSum=callableStatement.getDouble(3);
    Double palletSum=callableStatement.getDouble(4);
    int shipPlateCount=callableStatement.getInt(5);
    int palletCount=callableStatement.getInt(6);
    return new ReportVo( personCount, partyGroupCount, shipPlateSum, palletSum, shipPlateCount, palletCount);
    }
    });
    return reportVo;
    }
  • 相关阅读:
    nginx内置高可用配置与第三方高可用模块nginx_ustream_check_mudule配置
    nginx+php,nginx+tomcat动静分离实战
    面向对象三大特性之多态与多态性
    面向对象三大特性之组合
    面向对象三大特性之继承与派生
    面向对象编程初探
    常用模块
    模块
    函数
    文件处理
  • 原文地址:https://www.cnblogs.com/xiqoqu/p/11647358.html
Copyright © 2011-2022 走看看