jdbc call procedure

  Connection con = session.connection();
  String procedure = "{call SP_XYZ(?,?) }";
  try {

   CallableStatement cstmt = con.prepareCall(procedure);
   cstmt.setInt(1, Integer.parseInt(Id));
   cstmt.registerOutParameter(2, OracleTypes.INTEGER);
   cstmt.executeUpdate();
   int importCount = cstmt.getInt(2);
   return importCount;

  } catch (SQLException e) {
   // TODO 自動生成 catch 塊
   e.printStackTrace();
   //return -1;
   throw new Exception(e.getMessage());
  }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章