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;
    }
  • 相关阅读:
    Windows Vista 桌面窗口管理器(1)
    Thinking in Java读书笔记――数组
    php图片上传存储源码,可实现预览
    php at(@)符号的用法简介
    Apache如何添加虚拟目录
    也发个PHP人民币金额数字转中文大写
    PHP Get Current URL
    Zend Studio下的PHP代码调试
    PHP url 加密解密函数
    使用新浪微博php SDK的一点记录
  • 原文地址:https://www.cnblogs.com/xiqoqu/p/11647358.html
Copyright © 2011-2022 走看看