Java Reference
In-Depth Information
Table 11.13. Table key methods on the StoredProcedureQuery interface for setting parameters
Method
Description
setParameter(Parameter<T> param, T
value)
Sets a parameter
setParameter( Parameter<Calendar>
param, Calendar value, TemporalType
temporalType)
Sets a parameter that's a calendar
setParameter(Parameter<Date> param,
Date value, TemporalType tempor-
alType)
Sets a parameter that's a date
setParameter(String name, Object
value)
Sets a parameter via a string name
setParameter(String name, Calendar
value, TemporalType temporalType)
Sets a calendar parameter via a string name
setParameter(String name, Date value,
TemporalType temporalType)
Sets a date parameter via a string name
setParameter(int position, Object value) Sets parameter via a position
setParameter(int position, Calendar
value, TemporalType temporalType)
Sets calendar parameter via a position
setParameter(int position, Date value,
TemporalType temporalType)
Sets date parameter via a position
Object getOutputParameterValue( int
position)
Retrieves an IN or OUT parameter that was passed back via position
Object getOutputParameterValue(
String parameterName)
Retrieve an IN or OUT parameter that was passed back via a string
registerStoredProcedureParameter(
String parameterName, Class type,
ParameterMode mode)
Registers a stored procedure parameter
int getUpdateCount()
Retrieves the update count or -1 if there's no pending result
boolean execute()
Executes the query
To get a better idea of how to use stored procedures, let's look at a trivial example from Ac-
tionBazaar. An example stored procedure from ActionBazaar, written in pgSQL, is shown
in listing 11.10 . pgSQL is one of the scripting languages supported by PostgreSQL—it's
very similar to PL/SQL. The language isn't important, but it highlights the fact that by
using stored procedures, an Enterprise application becomes tied to a particular database,
which may or may not be an issue.
 
Search WWH ::




Custom Search