Modifier and Type | Method and Description |
---|---|
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 . |
Statement |
bind(int index,
Object value)
Bind a non-
null value to an indexed parameter. |
Statement |
bind(String name,
Object value)
Bind a non-
null to a named parameter. |
Statement |
bindNull(int index,
Class<?> type)
Bind a
null value to an indexed parameter. |
Statement |
bindNull(String name,
Class<?> type)
Bind a
null value to a named parameter. |
Publisher<? extends Result> |
execute()
Executes one or more SQL statements and returns the
Result s. |
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. |
default Statement |
returnGeneratedValues(String... columns)
|
Statement add()
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();
Statement
IllegalStateException
- if the statement is parametrized and not all parameter values are providedStatement bind(int index, Object value)
null
value to an indexed parameter. Indexes are zero-based.index
- the index to bind tovalue
- the value to bindStatement
IllegalArgumentException
- if value
is null
IndexOutOfBoundsException
- if the parameter index
is out of rangeStatement bind(String name, Object value)
null
to a named parameter.name
- the name of identifier to bind tovalue
- the value to bindStatement
IllegalArgumentException
- if name
or value
is null
Statement bindNull(int index, Class<?> type)
null
value to an indexed parameter. Indexes are zero-based.index
- the index to bind totype
- the type of null valueStatement
IllegalArgumentException
- if type
is null
IndexOutOfBoundsException
- if the parameter index
is out of rangeStatement bindNull(String name, Class<?> type)
null
value to a named parameter.name
- the name of identifier to bind totype
- the type of null valueStatement
IllegalArgumentException
- if name
or type
is null
Publisher<? extends Result> execute()
Result
s.
Result
objects must be fully consumed to ensure full execution of the Statement
.
This statement is executed additionally for each binding saved through add()
.Result
s, returned by each statementIllegalStateException
- if the statement is parametrized and not all parameter values are provideddefault Statement returnGeneratedValues(String... columns)
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.
columns
- the names of the columns to returnStatement
IllegalArgumentException
- if columns
, or any item in columns
is null
default Statement fetchSize(int rows)
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.
rows
- the number of rows to fetchStatement
Copyright © 2021. All rights reserved.