title: Calling Stored Procedure in Java class
body: <p>How to call this stored procedure in java class? and declare a string variable equal to it?</p>
  
  <p><strong>GenORFinalSP</strong>(name of SP)</p>
  
  <pre><code>BEGIN
  
  DECLARE temp_OR VARCHAR(50);
  
  CALL GenORSP(xRCO, xReceipt, @tempCount, @tempORNo);
  
  SET xROR = @tempORNo;
  
  WHILE xROR = (SELECT TPAY_RECEIPT_NO FROM tbl_tax_payment WHERE TPAY_RECEIPT_NO = xROR) 
      DO
          CALL GenORSP(xRCO, xReceipt, @tempCount, @tempORNo);
  END WHILE;
  
  SET xROR = @tempORNo;
  
  SET xCount = @tempCount;
  
  END
  </code></pre>
  
  <p>for example I want to declare a string variable test equal to it.</p>
  
  <pre><code>String test = GenORFinalSP();
  </code></pre>
  
  <p><strong>updated:</strong>
  this is the code of <code>GenORSP</code></p>
  
  <pre><code>BEGIN
  
  DECLARE var_MAX BIGINT(20);
  DECLARE temp_COUNT BIGINT(20);
  DECLARE var_YEAR VARCHAR(4);
  DECLARE var_tempYEAR VARCHAR(4);
  DECLARE var_END INT(1);
  
  SET temp_COUNT = 0;
  SET var_END  = 0;
  SET var_YEAR = YEAR(CURRENT_TIMESTAMP);
  
      SELECT ( CASE WHEN MAX(TPAY_COUNTER) IS NULL THEN 0 ELSE MAX(TPAY_COUNTER) END ), YEAR (DATE(TPAY_ISSUED_DATE)) INTO var_MAX, var_tempYEAR FROM tbl_tax_payment where TPAY_ISSUED_DATE = (SELECT MAX(TPAY_ISSUED_DATE) FROM tbl_tax_payment WHERE RCO_CODE = xRCO AND RECEIPT_TYPE = xReceipt AND YEAR(DATE(TPAY_ISSUED_DATE)) = YEAR(current_date) AND TPAY_COUNTER = (
          SELECT
              MAX(TPAY_COUNTER)
          FROM
              tbl_tax_payment
          WHERE
              RCO_CODE = xRCO
          AND RECEIPT_TYPE = xReceipt
          AND YEAR (DATE(TPAY_ISSUED_DATE)) = YEAR (CURRENT_DATE)
      )) AND TPAY_COUNTER = (
              SELECT
                  MAX(TPAY_COUNTER)
              FROM
                  tbl_tax_payment
              WHERE
              RCO_CODE = xRCO
          AND RECEIPT_TYPE = xReceipt
              AND YEAR (DATE(TPAY_ISSUED_DATE)) = YEAR (CURRENT_DATE)
          );
  
  
  
          IF var_YEAR &lt;&gt; var_tempYEAR THEN
  
              SET var_END = (SELECT IF(YEAR(current_date) = var_tempYEAR,0,1));
  
              IF var_END = 1 THEN
  
                  SET var_MAX = 0;
  
              END IF;
  
          END IF;
  
  
          IF var_MAX = 0 THEN 
  
              SET temp_COUNT = 1;
              SET var_OR = CONCAT(xReceipt, var_YEAR, '-', xRCO, '-', LPAD(temp_COUNT, 6, '0'));
  
          ELSE 
  
              SET temp_COUNT = var_MAX + 1;
              SET var_OR = CONCAT(xReceipt, var_YEAR, '-', xRCO, '-', LPAD(temp_COUNT, 6, '0'));
  
          END IF;
  
  
              SET var_COUNT = temp_COUNT;
  
  
  
  END
  </code></pre>