Error in JDBC code calling a stored function which returns a value
<p>I'm trying to print the returned value of a MySQL stored <em>function</em> from the JDBC code which is as follows (I am using MySQL Server 5.7.13):</p>

<pre><code>package jdbc;

import java.sql.DriverManager;
import java.sql.*;
import java.util.Scanner;


public class CallableStatementsCallingFunctions {
    public static void main(String... syrt)
    {
      try
     {
        try
        {                
            Class.forName("com.mysql.jdbc.Driver");
        }
        catch(ClassNotFoundException e)
        {
          System.out.println("Error(class): "+ e);
        }
        try
        {
         Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/collablestatement","root","mysql") ;
         CallableStatement cs = conn.prepareCall("{call ?:=getBalance1(?)}");
         String s = new Scanner(System.in).nextLine();
         cs.registerOutParameter(1,Types.INTEGER);
         cs.setInt(2,Integer.parseInt(s));             
         cs.execute();
         System.out.println("Account number :" + cs.getInt(1));
         conn.close();
        } 
        catch(SQLException e)
        {
          System.out.println("Error(SQL) : "+e);
        }
    }
    catch(Exception e)
    {
      System.out.println("Error(Fro outer try) : "+ e);
    }
}
</code></pre>

<p>}</p>

<p>the stored function <code>getBalance1(acno)</code> is shown here </p>

<p><img src="https://i.stack.imgur.com/0pmqw.png" alt="getBalance(acno numeric)"> </p>

<p>my code output is shown here </p>

<p><img src="https://i.stack.imgur.com/AyXdF.png" alt="jdbc output"></p>

<p>I am getting the output from the SQL command but in JDBC I am getting and <code>SQLException</code> saying that </p>

<blockquote>
  <p>parameter 1 is not an output parameter </p>
</blockquote>

<p>I know that parameter 1 has been used as the placeholder of the returned value from the function in jdbc code. In <code>prepareCall</code> I also tried the syntax -  <code>{?:= call getBalance1(?)}</code> , but  even then getting the same Exception. </p>

<p>Why am I getting the exception?</p>