spring-framework / org.springframework.jdbc.core.namedparam / NamedParameterJdbcOperations / execute

execute

@Nullable abstract fun <T : Any> execute(sql: String, paramSource: SqlParameterSource, action: PreparedStatementCallback<T>): T

Execute a JDBC data access operation, implemented as callback action working on a JDBC PreparedStatement. This allows for implementing arbitrary data access operations on a single Statement, within Spring's managed JDBC environment: that is, participating in Spring-managed transactions and converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.

The callback action can return a result object, for example a domain object or a collection of domain objects.

Parameters

sql - SQL to execute

paramSource - container of arguments to bind to the query

action - callback object that specifies the action

Exceptions

DataAccessException - if there is any problem

Return
a result object returned by the action, or null

@Nullable abstract fun <T : Any> execute(sql: String, paramMap: MutableMap<String, *>, action: PreparedStatementCallback<T>): T

Execute a JDBC data access operation, implemented as callback action working on a JDBC PreparedStatement. This allows for implementing arbitrary data access operations on a single Statement, within Spring's managed JDBC environment: that is, participating in Spring-managed transactions and converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.

The callback action can return a result object, for example a domain object or a collection of domain objects.

Parameters

sql - SQL to execute

paramMap - map of parameters to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type)

action - callback object that specifies the action

Exceptions

DataAccessException - if there is any problem

Return
a result object returned by the action, or null

@Nullable abstract fun <T : Any> execute(sql: String, action: PreparedStatementCallback<T>): T

Execute a JDBC data access operation, implemented as callback action working on a JDBC PreparedStatement. This allows for implementing arbitrary data access operations on a single Statement, within Spring's managed JDBC environment: that is, participating in Spring-managed transactions and converting JDBC SQLExceptions into Spring's DataAccessException hierarchy.

The callback action can return a result object, for example a domain object or a collection of domain objects.

Parameters

sql - SQL to execute

action - callback object that specifies the action

Exceptions

DataAccessException - if there is any problem

Return
a result object returned by the action, or null