Package com.couchbase.client.java.query
Class PrepareStatement
java.lang.Object
com.couchbase.client.java.query.PrepareStatement
- All Implemented Interfaces:
SerializableStatement
,Statement
,Serializable
public class PrepareStatement extends Object implements SerializableStatement
A PREPARE
Statement
that wraps another Statement in order to send it
to the server and produce a PreparedPayload
.- Since:
- 2.1
- Author:
- Simon Baslé
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static String
PREPARE_PREFIX
a prefix to be used in order to prepare a named query plan for a statement -
Method Summary
Modifier and Type Method Description Statement
originalStatement()
static PrepareStatement
prepare(Statement statement)
Construct aPrepareStatement
from a select-likeStatement
.static PrepareStatement
prepare(Statement statement, String preparedName)
Construct aPrepareStatement
from a select-likeStatement
and give it a name.static PrepareStatement
prepare(String statement)
Construct aPrepareStatement
from a statement inString
format.String
preparedName()
String
toString()
-
Field Details
-
PREPARE_PREFIX
a prefix to be used in order to prepare a named query plan for a statement- See Also:
- Constant Field Values
-
-
Method Details
-
originalStatement
-
preparedName
-
toString
-
prepare
Construct aPrepareStatement
from a select-likeStatement
. Note that passing aPrepareStatement
will return it directly, whereas passing aPreparedPayload
will reuse thePreparedPayload.preparedName()
.- Parameters:
statement
- theStatement
to prepare.- Returns:
- the prepared statement.
- Throws:
IllegalArgumentException
- when statement cannot be prepared.
-
prepare
Construct aPrepareStatement
from a select-likeStatement
and give it a name. Note that passing aPrepareStatement
or aPreparedPayload
will reuse theoriginal statement
but use the given name.- Parameters:
statement
- theStatement
to prepare.preparedName
- the name to give to the prepared statement- Returns:
- the prepared statement.
- Throws:
IllegalArgumentException
- when statement cannot be prepared.
-
prepare
Construct aPrepareStatement
from a statement inString
format. Statement shouldn't begin with "PREPARE", otherwise a syntax error may be returned by the server.- Parameters:
statement
- the statement to prepare (not starting with "PREPARE").- Returns:
- the prepared statement.
- Throws:
NullPointerException
- when statement is null.
-