Class Call

All Implemented Interfaces:
Closeable, AutoCloseable, Configurable<Call>

public class Call extends SqlStatement<Call>
Used for invoking stored procedures. The most common way to use this is to register 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 Details

  • Method Details

    • registerOutParameter

      public Call registerOutParameter(int position, int sqlType)
      Register a positional output parameter.
      Parameters:
      position - the parameter position (zero-based)
      sqlType - an SQL type constant as defined by Types or by the JDBC vendor.
      Returns:
      self
    • registerOutParameter

      public Call registerOutParameter(int position, int sqlType, CallableStatementMapper mapper)
      Register a positional output parameter.
      Parameters:
      position - the parameter position (zero-based)
      sqlType - an SQL type constant as defined by Types or by the JDBC vendor.
      mapper - a mapper which converts the CallableStatement to a desired output type.
      Returns:
      self
    • registerOutParameter

      public Call registerOutParameter(String name, int sqlType)
      Register a named output parameter.
      Parameters:
      name - the parameter name
      sqlType - an SQL type constant as defined by Types or by the JDBC vendor.
      Returns:
      self
    • registerOutParameter

      public Call registerOutParameter(String name, int sqlType, CallableStatementMapper mapper)
      Register a named output parameter.
      Parameters:
      name - the parameter name
      sqlType - an SQL type constant as defined by Types or by the JDBC vendor.
      mapper - a mapper which converts the CallableStatement to a desired output type.
      Returns:
      self
    • invoke

      public OutParameters 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

      public void invoke(Consumer<OutParameters> resultConsumer)
      Invoke the callable statement and process its OutParameters results.
    • invoke

      public <T> T invoke(Function<OutParameters,T> resultComputer)
      Invoke the callable statement and process its OutParameters results, returning a computed value of type T.
    • setFetchSize

      public Call setFetchSize(int fetchSize)
      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

      public Call setMaxRows(int maxRows)
      Specify the maximum number of rows the call is to return. This uses the underlying JDBC Statement.setMaxRows(int)}.
      Parameters:
      maxRows - maximum number of rows to return
      Returns:
      modified call
      Since:
      3.43.0
    • setMaxFieldSize

      public Call setMaxFieldSize(int maxFields)
      Specify the maximum field size in the result set. This uses the underlying JDBC Statement.setMaxFieldSize(int)
      Parameters:
      maxFields - maximum field size
      Returns:
      modified call
      Since:
      3.43.0
    • concurrentUpdatable

      public Call 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

      public final Handle getHandle()
    • getConfig

      public ConfigRegistry getConfig()
      Description copied from interface: Configurable
      Returns the configuration registry associated with this object.
      Specified by:
      getConfig in interface Configurable<This>
      Returns:
      the configuration registry associated with this object.
    • getContext

      public final StatementContext getContext()
      Returns the statement context associated with this statement.
      Returns:
      the statement context associated with this statement.
    • attachToHandleForCleanup

      @Beta public final Call 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:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object