java call Oracle procedure 获取返回值

   public void printApplyProc(String p_gv_no, String p_print_type) {

      // TODO Auto-generated method stub

      String sql = null;

      final String pgvno = p_gv_no;

      final String pprinttype = p_print_type;

      sql = "{CALL E_SHOP_UTIL.PRINT_APPLY(?, ?,?,?)}";//后两个是out put 参数

      log.debug("printApplyProc instance");

      try {

         jdbcTemplate.execute(sql, new CallableStatementCallback() {

            public Object doInCallableStatement(CallableStatement cs)

                   throws SQLException {

                cs.setString(1, pgvno);

                cs.setString(2, pprinttype);

                cs.registerOutParameter(3, Types.VARCHAR);

                cs.registerOutParameter(4, Types.VARCHAR);

                cs.execute();

                return new Integer(cs.getString(3));

            }

         });

         log.debug("printApplyProc successful");

      } catch (RuntimeException re) {

         log.error("printApplyProc failed", re);

         re.printStackTrace();

         throw re;

      }

   }


你可能感兴趣的:(java call Oracle procedure 获取返回值)