Java Reference
In-Depth Information
procedure-element is expressed as
{
| [ DYNAMIC ] RESULT SETS INTEGER
| LANGUAGE { JAVA }
| DeterministicCharacteristic
| EXTERNAL NAME string
| PARAMETER STYLE JAVA
| EXTERNAL SECURITY { DEFINER | INVOKER }
| { NO SQL | MODIFIES SQL DATA | CONTAINS SQL | READS SQL
DATA }
}
Anything between [] is optional, the * to the right of [] indicates that anything
betweenthesemetacharacterscanappearzeroormoretimes,the {} metacharacterssur-
round a list of items, and | separates possible items—only one of these items can be
specified.
For example, CREATE PROCEDURE FIRE(IN ID INTEGER) PARAMETER
STYLE JAVA LANGUAGE JAVA DYNAMIC RESULT SETS 0 EXTERNAL
NAME 'EmployeeDB.fire' createsastoredprocedurenamed FIRE .Thisproced-
urespecifiesaninputparameternamed ID andisassociatedwitha public static
method named fire in a public class named EmployeeDB .
After creating the stored procedure, you need to obtain a CallableStatement
implementation instance in order to call that procedure, and you do so by invoking
oneof Connection 's prepareCall() methods;forexample, CallableState-
ment prepareCall(String sql) .
The string passed to prepareCall() is an escape clause (RDBMS-independent
syntax)consistingofanopen { ,followedbytheword call ,followedbyaspace,fol-
lowedbythenameofthestoredprocedure,followedbyaparameterlistwith“ ? ”place-
holder characters for the arguments that will be passed, followed by a closing } .
Note Escape clauses are JDBC's way of smoothing out some of the differences in
how different RDBMS vendors implement SQL. When a JDBC driver detects escape
syntax,itconvertsitintothecodethattheparticularRDBMSunderstands.Thismakes
escape syntax RDBMS-independent.
Once you have a CallableStatement reference, you pass arguments to these
parameters in the same way as with PreparedStatement . The following example
demonstrates:
Search WWH ::




Custom Search