title: Java - MySQL Calling Stored Procedure
body: <p>I'm trying to call a Stored Procedure from Java. However, what I did was looking for a Function instead. What did I miss? Here's what I have tried so far;<br><br></p>
  
  <pre><code>open();
  
  try {
  
      statement = conn.prepareStatement(StringConstant.PROC_GET_POSITIONS);
      ResultSet resultSet = statement.executeQuery();
  
      while( resultSet.next() ){
  
          System.out.println(resultSet.getString(0));
  
      }
  
  } catch ( SQLException sqlEx ) {
      sqlEx.printStackTrace();
  }
  
  close();
  </code></pre>
  
  <p>Throwing this Exception;</p>
  
  <pre><code>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: FUNCTION test.get_positions does not exist
  </code></pre>
  
  <p>This is how the stored procedure is written (This is for the purpose of testing):</p>
  
  <pre><code>CREATE FUNCTION get_positions(OUT o_position VARCHAR(25))
  BEGIN
  
    SELECT pos_name
    INTO o_position
    FROM master_position;
  
  END;
  </code></pre>
  
  <p>The reason I made the question is that SO suggested this titles:<br></p>
  
  <p>-automate call stored procedure 1<br>
  -How to Call a Stored Procedure within a Stored Procedure in MySQL 1<br>
  -Calling a Stored Procedure in Hibernate 2<br>
  -Call a Stored Procedure From a Stored Procedure and/or using COUNT 2<br>
  -mysql stored procedure call hibernate 2<br>
  <br>
  None of those answered my question.</p>