Class Call
- All Implemented Interfaces:
Closeable, AutoCloseable, Configurable<Call>
Used for invoking stored procedures. The most common way to use this is to register
There are some databases, most prominently MS SqlServer that only support limited OUT parameters, especially do not support cursors (for MS SqlServer see Using a stored procedure with output parameters). Those databases may support returning a result set from the procedure invocation, to access this result set use the
OutParameters with the call and then use the invoke() method
to retrieve the return values from the invoked procedure.
There are some databases, most prominently MS SqlServer that only support limited OUT parameters, especially do not support cursors (for MS SqlServer see Using a stored procedure with output parameters). Those databases may support returning a result set from the procedure invocation, to access this result set use the
OutParameters.getResultSet() method to retrieve
the result set from the underlying call operation.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal CallRegisters with the handle for cleaning when the handle is closed.voidclose()Specify that the result set should be concurrent updatable.Returns the configuration registry associated with this object.final StatementContextReturns the statement context associated with this statement.final Handleinvoke()Invoke the callable statement.voidinvoke(Consumer<OutParameters> resultConsumer) Invoke the callable statement and process itsOutParametersresults.<T> Tinvoke(Function<OutParameters, T> resultComputer) Invoke the callable statement and process itsOutParametersresults, returning a computed value of typeT.registerOutParameter(int position, int sqlType) Register a positional output parameter.registerOutParameter(int position, int sqlType, CallableStatementMapper mapper) Register a positional output parameter.registerOutParameter(String name, int sqlType) Register a named output parameter.registerOutParameter(String name, int sqlType, CallableStatementMapper mapper) Register a named output parameter.setFetchSize(int fetchSize) Specify the fetch size for the call.setMaxFieldSize(int maxFields) Specify the maximum field size in the result set.setMaxRows(int maxRows) Specify the maximum number of rows the call is to return.Methods inherited from class SqlStatement
bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bind, bindArray, bindArray, bindArray, bindArray, bindArray, bindArray, bindArray, bindArray, bindASCIIStream, bindASCIIStream, bindBean, bindBean, bindBeanList, bindBinaryStream, bindBinaryStream, bindBySqlType, bindBySqlType, bindByType, bindByType, bindByType, bindByType, bindByType, bindByType, bindFields, bindFields, bindList, bindList, bindList, bindList, bindList, bindList, bindList, bindMap, bindMethods, bindMethods, bindMethodsList, bindNamedArgumentFinder, bindNull, bindNull, bindNVarchar, bindNVarchar, bindPojo, bindPojo, bindPojo, bindPojo, bindPojo, bindPojo, cleanupHandleCommit, cleanupHandleRollback, defineList, defineList, defineNamedBindings, setQueryTimeout, toStringModifier and TypeMethodDescriptionfinal Callbind(int position, boolean value) Bind an argument positionallyfinal Callbind(int position, byte value) Bind an argument positionallyfinal Callbind(int position, byte[] value) Bind an argument positionallyfinal Callbind(int position, char value) Bind an argument positionallyfinal Callbind(int position, double value) Bind an argument positionallyfinal Callbind(int position, float value) Bind an argument positionallyfinal Callbind(int position, int value) Bind an argument positionallyfinal Callbind(int position, long value) Bind an argument positionallyfinal Callbind(int position, short value) Bind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal Callbind(int position, BigDecimal value) Bind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyfinal CallBind an argument positionallyUsed if you need to have some exotic parameter bound.final CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal Callbind(String name, BigDecimal value) Bind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by namefinal CallBind an argument by nameUsed if you need to have some exotic parameter bound.final CallBind an Iterable as a SQL array.final CallBind a Java array as a SQL array, casting each element to a new type.final CallBind an Iterator as a SQL array.final <T> CallbindArray(int pos, T... array) Bind a Java array as a SQL array.final CallBind an Iterable as a SQL array.final CallBind a Java array as a SQL array, casting each element to a new type.final CallBind an Iterator as a SQL array.final <T> CallBind a Java array as a SQL array.final CallbindASCIIStream(int position, InputStream value, int length) Bind an argument positionallyfinal CallbindASCIIStream(String name, InputStream value, int length) Bind an argument by nameBinds named parameters from JavaBean properties on the argument.Binds named parameters from JavaBean properties on the bean argument, with the given prefix.final CallbindBeanList(String key, List<?> values, List<String> propertyNames) Bind a parameter for each value in the given list * number of property names, and defines an attribute as the comma-separated list of parameter references (using colon prefix).final CallbindBinaryStream(int position, InputStream value, int length) Bind an argument positionallyfinal CallbindBinaryStream(String name, InputStream value, int length) Bind an argument by namefinal CallbindBySqlType(int position, Object value, int sqlType) Bind a value using a specific type fromjava.sql.Typesvia PreparedStatement#setObject(int, Object, int)final CallbindBySqlType(String name, Object value, int sqlType) Bind a value using a specific type fromjava.sql.Typesvia PreparedStatement#setObject(int, Object, int)final CallbindByType(int position, Object value, Type argumentType) Bind an argument dynamically by the type passed in.final CallbindByType(int position, Object value, GenericType<?> argumentType) Bind an argument dynamically by the generic type passed in.final CallbindByType(int position, Object value, QualifiedType<?> argumentType) Bind an argument dynamically by the qualified type passed in.final CallbindByType(String name, Object value, Type argumentType) Bind an argument dynamically by the type passed in.final CallbindByType(String name, Object value, GenericType<?> argumentType) Bind an argument dynamically by the generic type passed in.final CallbindByType(String name, Object value, QualifiedType<?> argumentType) Bind an argument dynamically by the type passed in.bindFields(Object object) Binds public fields of the specified object as arguments for the query.bindFields(String prefix, Object object) Binds public fields of the specified object as arguments for the query.final Callfinal Callfinal Callfinal CallbindList(BiConsumer<SqlStatement, String> onEmpty, String key, Iterable<?> values) final CallbindList(BiConsumer<SqlStatement, String> onEmpty, String key, Object... values) final CallbindList(BiConsumer<SqlStatement, String> onEmpty, String key, Iterator<?> values) final CallbindList(BiConsumer<SqlStatement, String> onEmpty, String key, List<?> values) Bind a parameter for each value in the given list, and defines an attribute as the comma-separated list of parameter references (using colon prefix).Binds named parameters from a map of String to Object instancesbindMethods(Object object) Binds methods with no parameters on the argument.bindMethods(String prefix, Object object) Binds methods with no parameters on the argument, with the given prefix.final CallbindMethodsList(String key, Iterable<?> values, List<String> methodNames) For each value given, create a tuple by invoking each given method in order, and bind the tuple into aVALUES (...)format insert clause.bindNamedArgumentFinder(NamedArgumentFinder namedArgumentFinder) Binds a newNamedArgumentFinder.final CallbindNull(int position, int sqlType) Bind NULL to be set for a given argument.final CallBind NULL to be set for a given argument.final CallbindNVarchar(int position, String value) Bind aStringargument positionally, asNVARCHARtype.final CallbindNVarchar(String name, String value) Bind aStringargument by name, asNVARCHARtype.Binds named parameters from object properties on the argument.Binds named parameters from object properties on the argument.bindPojo(Object pojo, GenericType<?> type) Binds named parameters from object properties on the argument.Binds named parameters from object properties on the bean argument, with the given prefix.Binds named parameters from object properties on the bean argument, with the given prefix.bindPojo(String prefix, Object pojo, GenericType<?> type) Binds named parameters from object properties on the bean argument, with the given prefix.Transfer ownership of the handle to the statement: when the statement is closed, commit the handle's transaction (if one exists) and close the handle.When the statement is closed, roll it back then close the owning Handle.final CalldefineList(String key, Object... values) Define an attribute as the comma-separatedStringfrom the elements of thevaluesargument.final CalldefineList(String key, List<?> values) Define an attribute as the comma-separatedStringfrom the elements of thevaluesargument.Define all bound arguments that don't already have a definition with a boolean indicating their presence.setQueryTimeout(int seconds) Set the query timeout, in seconds, on the prepared statement.toString()Methods inherited from interface Configurable
addCustomizer, configure, define, getConfig, registerArgument, registerArgument, registerArrayType, registerArrayType, registerArrayType, registerArrayType, registerCodecFactory, registerCollector, registerCollector, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerColumnMapper, registerExtension, registerRowMapper, registerRowMapper, registerRowMapper, registerRowMapper, setMapKeyColumn, setMapValueColumn, setSqlArrayArgumentStrategy, setSqlLogger, setSqlParser, setTemplateEngine, setTimingCollectorModifier and TypeMethodDescriptiondefault CalladdCustomizer(StatementCustomizer customizer) default <C extends JdbiConfig<C>>
CallPasses the configuration object of the given type to the configurer, then returns this object.default CallConvenience method forgetConfig(SqlStatements.class).define(key, value)default <C extends JdbiConfig<C>>
CGets the configuration object of the given type, associated with this object.default CallregisterArgument(ArgumentFactory factory) Convenience method forgetConfig(Arguments.class).register(factory)default CallregisterArgument(QualifiedArgumentFactory factory) Convenience method forgetConfig(Arguments.class).register(factory)default CallregisterArrayType(Class<?> elementType, String sqlTypeName) Convenience method forgetConfig(SqlArrayTypes.class).register(elementType, sqlTypeName)default <T> CallregisterArrayType(Class<T> elementType, String sqlTypeName, Function<T, ?> conversion) Convenience method for registering an array type asSqlArrayTypeFactory.of(Class, String, Function).default CallregisterArrayType(SqlArrayType<?> arrayType) Convenience method forgetConfig(SqlArrayTypes.class).register(arrayType)default CallregisterArrayType(SqlArrayTypeFactory factory) Convenience method forgetConfig(SqlArrayTypes.class).register(factory)default CallregisterCodecFactory(CodecFactory codecFactory) Convenience method to register aCodecFactory.default CallregisterCollector(Type collectionType, Collector<?, ?, ?> collector) Convenience method forgetConfig(JdbiCollectors.class).register(CollectorFactory.collectorFactory(collectionType, collector))default CallregisterCollector(CollectorFactory factory) Convenience method forgetConfig(JdbiCollectors.class).register(factory)default CallregisterColumnMapper(Type type, ColumnMapper<?> mapper) Convenience method forgetConfig(ColumnMappers.class).register(type, mapper)default <T> CallregisterColumnMapper(GenericType<T> type, ColumnMapper<T> mapper) Convenience method forgetConfig(ColumnMappers.class).register(type, mapper)default CallregisterColumnMapper(ColumnMapper<?> mapper) Convenience method forgetConfig(ColumnMappers.class).register(mapper)default CallregisterColumnMapper(ColumnMapperFactory factory) Convenience method forgetConfig(ColumnMappers.class).register(factory)default CallConvenience method forgetConfig(ColumnMappers.class).register(factory)default <T> CallregisterColumnMapper(QualifiedType<T> type, ColumnMapper<T> mapper) Convenience method forgetConfig(ColumnMappers.class).register(type, mapper)default CallregisterExtension(ExtensionFactory factory) Convenience method forgetConfig(Extensions.class).register(factory)default CallregisterRowMapper(Type type, RowMapper<?> mapper) Convenience method forgetConfig(RowMappers.class).register(type, mapper)default <T> CallregisterRowMapper(GenericType<T> type, RowMapper<T> mapper) Convenience method forgetConfig(RowMappers.class).register(type, mapper)default CallregisterRowMapper(RowMapper<?> mapper) Convenience method forgetConfig(RowMappers.class).register(mapper)default CallregisterRowMapper(RowMapperFactory factory) Convenience method forgetConfig(RowMappers.class).register(factory)default CallsetMapKeyColumn(String keyColumn) Convenience method forgetConfig(MapEntryMappers.class).setKeyColumn(keyColumn)default CallsetMapValueColumn(String valueColumn) Convenience method forgetConfig(MapEntryMappers.class).setValueColumn(valueColumn)default CallConvenience method forgetConfig(SqlArrayTypes.class).setArgumentStrategy(strategy)default CallsetSqlLogger(SqlLogger sqlLogger) default CallsetSqlParser(SqlParser parser) Convenience method forgetConfig(SqlStatements.class).setSqlParser(rewriter)default CallsetTemplateEngine(TemplateEngine templateEngine) Convenience method forgetConfig(SqlStatements.class).setTemplateEngine(rewriter)default CallsetTimingCollector(TimingCollector collector) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
Call
-
Call
-
-
Method Details
-
registerOutParameter
-
registerOutParameter
Register a positional output parameter. For INOUT parameters, callSqlStatement.bind(int, Object)before this method; the existing binding will be captured and sent as the input value.- Parameters:
position- the parameter position (zero-based)sqlType- an SQL type constant as defined byTypesor by the JDBC vendor.mapper- a mapper which converts theCallableStatementto a desired output type.- Returns:
- self
-
registerOutParameter
-
registerOutParameter
Register a named output parameter. For INOUT parameters, callSqlStatement.bind(String, Object)before this method; the existing binding will be captured and sent as the input value.- Parameters:
name- the parameter namesqlType- an SQL type constant as defined byTypesor by the JDBC vendor.mapper- a mapper which converts theCallableStatementto a desired output type.- Returns:
- self
-
invoke
Invoke the callable statement. Note that the statement will be cleaned up, so cursor-typed values may not work.- Returns:
- the output parameters resulting from the invocation.
-
invoke
Invoke the callable statement and process itsOutParametersresults. -
invoke
Invoke the callable statement and process itsOutParametersresults, returning a computed value of typeT. -
setFetchSize
Specify the fetch size for the call. This should cause the results to be fetched from the underlying RDBMS in groups of rows equal to the number passed. This is useful for doing chunked streaming of results when exhausting memory could be a problem.- Parameters:
fetchSize- the number of rows to fetch in a bunch- Returns:
- the modified call
- Since:
- 3.43.0
-
setMaxRows
Specify the maximum number of rows the call is to return. This uses the underlying JDBCStatement.setMaxRows(int)}.- Parameters:
maxRows- maximum number of rows to return- Returns:
- modified call
- Since:
- 3.43.0
-
setMaxFieldSize
Specify the maximum field size in the result set. This uses the underlying JDBCStatement.setMaxFieldSize(int)- Parameters:
maxFields- maximum field size- Returns:
- modified call
- Since:
- 3.43.0
-
concurrentUpdatable
Specify that the result set should be concurrent updatable. This will allow the update methods to be called on the result set produced by this Call.- Returns:
- the modified call
- Since:
- 3.43.0
-
getHandle
-
getConfig
Description copied from interface:ConfigurableReturns the configuration registry associated with this object.- Specified by:
getConfigin interfaceConfigurable<This>- Returns:
- the configuration registry associated with this object.
-
getContext
Returns the statement context associated with this statement.- Returns:
- the statement context associated with this statement.
-
attachToHandleForCleanup
Registers with the handle for cleaning when the handle is closed.
There are some situations where Statements need to be cleaned up to avoid resource leaks. This method registers the current Statement it with the Handle. If the statement or the context are cleaned by themselves, it will automatically unregister, so in normal operations, resources should not pool for cleanup with the Handle.- Since:
- 3.35.0
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
Configurable.setSqlLogger(SqlLogger)instead