Skip to content

Binding Parameters

Philippe Marschall edited this page Mar 22, 2017 · 14 revisions

The following ways to bind parameters are available:

  • by index
  • by index and type
  • by name
  • by name and type

per default in parameters are bound by index and out parameters are bound by index and type. The way to bind parameters can be changed by calling the ProcedureCallerFactory#withParameterRegistration method.

Types

The JDBC types are derived from Java types. The following default mapping is used

Java Type SQL type
String VARCHAR
Integer INTEGER
int INTEGER
Long BIGINT
long BIGINT
Short SMALLINT
short SMALLINT
Byte TINYINT
byte TINYINT
BigDecimal NUMERIC
BigInteger NUMERIC
Float REAL
float REAL
Double DOUBLE
double DOUBLE
Blob BLOB
Clob CLOB
NClob NCLOB
LocalDate DATE
LocalTime TIME
LocalDateTime TIMESTAMP
OffsetTime TIME WITH TIMEZONE
OffsetDateTime TIMESTAMP WITH TIMEZONE
java.sql.Date DATE
java.sql.Time TIME
java.sql.Timestamp TIMESTAMP
SQLXML SQLXML
Boolean BOOLEAN
boolean BOOLEAN
Collection ARRAY
array ARRAY

If the default implementation is not sufficient a either a custom implementation of TypeMapper and be passed or the @ParameterType annotation or the type attribute on the @OutParameter and @ReturnValue annotations can be used.

Note that JDBC requires that a type is always passed when registering an out parameter.

Names

For in parameter names you can either compile with -parameters and optionally use a NamingStrategy e.g. to perfix every parameter with p_. Or use the @ParameterName name annotation.

For out parameters use the name attribute on the @OutParameter annotation. For functions binding the return value by name is generally not possible.