Top Description Methods
io.r2dbc.spi

public Interface Statement

Imports
org.reactivestreams.Publisher, java.util.NoSuchElementException

A statement that can be executed multiple times in a prepared and optimized way. Bound parameters can be either scalar values (using type inference for the database parameter type) or Parameter objects.
See Also
Result, Row, Blob, Clob, Parameter

Method Summary

Modifier and TypeMethod and Description
public Statement

Returns:

this Statement
add
()

Save the current binding and create a new one to indicate the statement should be executed again with new bindings provided through subsequent calls to bind and bindNull.

public Statement

Returns:

this Statement
bind
(int
the index to bind to
index
,
Object
the value to bind
value
)

Bind a non-null value to an indexed parameter.

public Statement

Returns:

this Statement
bind
(String
the name of identifier to bind to
name
,
Object
the value to bind
value
)

Bind a non-null to a named parameter.

public Statement

Returns:

this Statement
bindNull
(int
the index to bind to
index
,
Class<?>
the type of null value
type
)

Bind a null value to an indexed parameter.

public Statement

Returns:

this Statement
bindNull
(String
the name of identifier to bind to
name
,
Class<?>
the type of null value
type
)

Bind a null value to a named parameter.

public Publisher<? extends Result>

Returns:

the Results, returned by each statement
execute
()

Executes one or more SQL statements and returns the Results.

public default Statement

Returns:

this Statement
fetchSize
(int
the number of rows to fetch
rows
)

Configures Statement to retrieve a fixed number of rows when fetching results from a query instead deriving fetch size from back pressure.

public default Statement

Returns:

this Statement
returnGeneratedValues
(String...
the names of the columns to return
columns
)

Configures Statement to return the generated values from any rows created by this Statement in the Result returned from execute().

Method Detail

addback to summary
public Statement add()

Save the current binding and create a new one to indicate the statement should be executed again with new bindings provided through subsequent calls to bind and bindNull. For example:

Statement statement = connection.createStatement("INSERT INTO books (author, publisher) VALUES ($1, $2)");
statement.bind(0, "John Doe").bind(1, "Happy Books LLC").add();
statement.bind(0, "Jane Doe").bind(1, "Scary Books Inc");
statement.execute();
Returns:Statement

this Statement

Exceptions
IllegalStateException:
if the statement is parametrized and not all parameter values are provided
bindback to summary
public Statement bind(int index, Object value)

Bind a non-null value to an indexed parameter. Indexes are zero-based.

Parameters
index:int

the index to bind to

value:Object

the value to bind

Returns:Statement

this Statement

Exceptions
IllegalArgumentException:
if value is null
IndexOutOfBoundsException:
if the parameter index is out of range
bindback to summary
public Statement bind(String name, Object value)

Bind a non-null to a named parameter.

Parameters
name:String

the name of identifier to bind to

value:Object

the value to bind

Returns:Statement

this Statement

Exceptions
IllegalArgumentException:
if name or value is null
NoSuchElementException:
if name is not a known name to bind
bindNullback to summary
public Statement bindNull(int index, Class<?> type)

Bind a null value to an indexed parameter. Indexes are zero-based.

Parameters
index:int

the index to bind to

type:Class<?>

the type of null value

Returns:Statement

this Statement

Exceptions
IllegalArgumentException:
if type is null
IndexOutOfBoundsException:
if the parameter index is out of range
bindNullback to summary
public Statement bindNull(String name, Class<?> type)

Bind a null value to a named parameter.

Parameters
name:String

the name of identifier to bind to

type:Class<?>

the type of null value

Returns:Statement

this Statement

Exceptions
IllegalArgumentException:
if name or type is null
NoSuchElementException:
if name is not a known name to bind
executeback to summary
public Publisher<? extends Result> execute()

Executes one or more SQL statements and returns the Results. Result objects must be fully consumed to ensure full execution of the Statement. This statement is executed additionally for each binding saved through add().

Returns:Publisher<? extends Result>

the Results, returned by each statement

Exceptions
IllegalStateException:
if the statement is parametrized and not all parameter values are provided
fetchSizeback to summary
public default Statement fetchSize(int rows)

Configures Statement to retrieve a fixed number of rows when fetching results from a query instead deriving fetch size from back pressure. If called multiple times, only the fetch size configured in the final invocation will be applied. If the value specified is zero, then the hint is ignored.

The default implementation of this method is a no op and the default value is zero.

Parameters
rows:int

the number of rows to fetch

Returns:Statement

this Statement

returnGeneratedValuesback to summary
public default Statement returnGeneratedValues(String... columns)

Configures Statement to return the generated values from any rows created by this Statement in the Result returned from execute(). If no columns are specified, implementations are free to choose which columns will be returned. If called multiple times, only the columns requested in the final invocation will be returned.

The default implementation of this method is a no-op.

Parameters
columns:String[]

the names of the columns to return

Returns:Statement

this Statement

Exceptions
IllegalArgumentException:
if columns, or any item in columns is null