title: Java - How to get ReturnCode from MySQL procedure?
body: <p>I have this stored procedure in MySQL</p>
  
  <pre><code>DELIMITER //
  create procedure spResetPassword (IN in_email VARCHAR (50))
  Begin
   Declare UserId int;
   Declare GUID varchar(64);
  
   Select UserId = nrIdentifikues
   from punetori
   where Email = in_email;
  
  if UserId IS NOT NULL then
      Set GUID = UUID();
  
      Insert into tblResetPasswordRequests (ID, UserID, ResetRequestDateTime) Values(GUID, UserId, NOW());
  
      Select 1 as ReturnCode, GUID as UniqueId, in_email as Email;
  else
      SELECT 0 as ReturnCode, NULL as UniqueId, NULL as Email;
  end if;
  end; //
  DELIMITER ;
  </code></pre>
  
  <p>And code from java :</p>
  
  <pre><code>Connection con = DB.Connect2DB("semp");
  
  try {
      CallableStatement sm = con.prepareCall("{call spResetPassword(?)}");
      sm.setString(1, txtEmail.getText());
      sm.execute();
  
      res = sm.getResultSet();
      int rCode = res.getInt("ReturnCode");
      while (res.next()) {
          if (rCode == 1) {
              SendPasswordResetEmail(res.getString("Email"), res.getString("GUID"));
              pnRequestReset.setVisible(false);
              con.close();
          }
      }
  } catch (Exception e2) {
      JOptionPane.showMessageDialog(null, e2.toString());
  }
  </code></pre>
  
  <p>The problem is that <code>ReturnCode</code> is not a column, therefore <code>res.getInt("ReturnCode");</code> won't work. How can I access that variable? This worked perfectly fine in C#</p>