Top Description Fields Methods
org.springframework.jdbc.core.namedparam

public Interface SqlParameterSource

Known Direct Implementers
org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource, org.springframework.jdbc.core.namedparam.EmptySqlParameterSource
Imports
org.springframework.jdbc.support.JdbcUtils, org.springframework.lang.Nullable

Interface that defines common functionality for objects that can offer parameter values for named SQL parameters, serving as argument for NamedParameterJdbcTemplate operations.

This interface allows for the specification of SQL type in addition to parameter values. All parameter values and types are identified by specifying the name of the parameter.

Intended to wrap various implementations like a Map or a JavaBean with a consistent interface.

Authors
Thomas Risberg, Juergen Hoeller
Since
2.0
See Also
NamedParameterJdbcOperations, NamedParameterJdbcTemplate, MapSqlParameterSource, BeanPropertySqlParameterSource

Field Summary

Modifier and TypeField and Description
public static final int
TYPE_UNKNOWN

Constant that indicates an unknown (or unspecified) SQL type.

Method Summary

Modifier and TypeMethod and Description
public default String[]

Returns:

the array of parameter names, or null if not determinable
getParameterNames
()

Enumerate all available parameter names if possible.

public default int

Returns:

the SQL type of the specified parameter, or TYPE_UNKNOWN if not known
getSqlType
(String
the name of the parameter
paramName
)

Determine the SQL type for the specified named parameter.

public default String

Returns:

the type name of the specified parameter, or null if not known
getTypeName
(String
the name of the parameter
paramName
)

Determine the type name for the specified named parameter.

public Object

Returns:

the value of the specified parameter
getValue
(String
the name of the parameter
paramName
)

Return the parameter value for the requested named parameter.

public boolean

Returns:

whether there is a value defined
hasValue
(String
the name of the parameter
paramName
)

Determine whether there is a value for the specified named parameter.

Field Detail

TYPE_UNKNOWNback to summary
public static final int TYPE_UNKNOWN

Constant that indicates an unknown (or unspecified) SQL type. To be returned from getType when no specific SQL type known.

See Also
getSqlType, java.sql.Types

Method Detail

getParameterNamesback to summary
public default String[] getParameterNames()

Enumerate all available parameter names if possible.

This is an optional operation, primarily for use with org.springframework.jdbc.core.simple.SimpleJdbcInsert and org.springframework.jdbc.core.simple.SimpleJdbcCall.

Returns:String[]

the array of parameter names, or null if not determinable

Annotations
@Nullable
Since
5.0.3
See Also
SqlParameterSourceUtils#extractCaseInsensitiveParameterNames
getSqlTypeback to summary
public default int getSqlType(String paramName)

Determine the SQL type for the specified named parameter.

Parameters
paramName:String

the name of the parameter

Returns:int

the SQL type of the specified parameter, or TYPE_UNKNOWN if not known

See Also
TYPE_UNKNOWN
getTypeNameback to summary
public default String getTypeName(String paramName)

Determine the type name for the specified named parameter.

Parameters
paramName:String

the name of the parameter

Returns:String

the type name of the specified parameter, or null if not known

Annotations
@Nullable
getValueback to summary
public Object getValue(String paramName) throws IllegalArgumentException

Return the parameter value for the requested named parameter.

Parameters
paramName:String

the name of the parameter

Returns:Object

the value of the specified parameter

Annotations
@Nullable
Exceptions
IllegalArgumentException:
if there is no value for the requested parameter
hasValueback to summary
public boolean hasValue(String paramName)

Determine whether there is a value for the specified named parameter.

Parameters
paramName:String

the name of the parameter

Returns:boolean

whether there is a value defined