title: How to call a MySQL stored procedure with multiple OUT parameters using JPA and Hibernate?
body: <p>I have following Mysql stored procedure with only OUT parameters, How I can call this stored procedure through hibernate in with only OUT Parameters?</p>
  
  <pre><code>CREATE PROCEDURE DBNAME.getStatistics (OUT A BIGINT UNSIGNED, OUT B BIGINT UNSIGNED, OUT C BIGINT UNSIGNED)
      BEGIN
  
          SELECT count(*) into A   from  DBNAME.Table1 where id =0;
          SELECT count(*) into B   from DBNAME.Table2 where id&gt;0 and id&lt;4;
          SELECT count(*) into C   from  DBNAME.Table3 where id&gt;4;
      END
  </code></pre>
  
  <p>EDIT</p>
  
  <p><strong>Following code I used in java to test the call of MySQL stored procedure (with only OUT Parameters) through hibernate(Java):</strong></p>
  
  <pre><code>Session session = HibernateUtil.getSessionFactory().openSession();
  
  Connection connection = session.connection();
  CallableStatement callable = null;
  
  try {
  
  callable = connection.prepareCall("{Call DBNAME.getStatistics(?,?,?)}");
  
  // three ?,?,? means three OUT parameter. 
  // If any parameters is IN type of
  // Lets say the first one then use : callable.setInt(1, 10);
  
      callable.registerOutParameter(1, Types.BIGINT);
      callable.registerOutParameter(2, Types.BIGINT);
      callable.registerOutParameter(3, Types.BIGINT);
      callable.executeUpdate();
  
      int value1 = callable.getInt(1);
      int value2 = callable.getInt(2);
      int value3 = callable.getInt(3);
  
  
      System.out.println(value1);
      System.out.println(value2);
      System.out.println(value3);
     } catch (SQLException e) {
         e.printStackTrace();
   }
  </code></pre>