java call Oracle procedure 獲取返回值

   public void printApplyProc(String p_gv_no, String p_print_type) {sql

      // TODO Auto-generated method stubspa

      String sql = null;debug

      final String pgvno = p_gv_no;get

      final String pprinttype = p_print_type;io

      sql = "{CALL E_SHOP_UTIL.PRINT_APPLY(?, ?,?,?)}";//後兩個是out put 參數jdbc

      log.debug("printApplyProc instance");bug

      try {im

         jdbcTemplate.execute(sql, new CallableStatementCallback() {error

            public Object doInCallableStatement(CallableStatement cs)db

                   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;

      }

   }

相關文章
相關標籤/搜索