Function handling
For calling stored procedures, JDBC provides the CallableStatement interface, which extends PreparedStatement. The API defines two escape syntaxes, which can be used to call a function on the database:
{? = call <procedure-name>[(?, ?, …)]}{call <procedure-name>[(?, ?, …)]}
The first form includes a return parameter, while the second one does not. The list of parameters passed to the function can contain both input and output parameters. If a function does not expect any parameters, it can be left out completely.
Examples of function handling are as follows:
{? = call random}: A call to a function without parameters{call setval(?, ?)}: A call without a return parameter{? = call substring(?, ?, ?)}: A call with the return parameter and the function parameter list
Calling a stored function
To execute a function from Java code, the first step is to get a CallableStatement from the open connection as follows:
CallableStatement statement =
...