public class CassandraStatement extends Object implements CassandraStatementExtras, Comparable<Object>, Statement
Statement.
It also implements CassandraStatementExtras interface providing extra methods not defined in JDBC API to
manage some properties specific to the Cassandra statements (e.g. consistency level).
| Modifier and Type | Field and Description |
|---|---|
protected ArrayList<String> |
batchQueries
The list of CQL queries contained into a single batch.
|
protected CassandraConnection |
connection
The Cassandra connection.
|
protected com.datastax.oss.driver.api.core.ConsistencyLevel |
consistencyLevel
The consistency level used for the statement.
|
protected String |
cql
The CQL statement.
|
protected ResultSet |
currentResultSet
The current result set for this statement.
|
protected static int |
DEFAULT_FETCH_SIZE
The default fetch size.
|
protected boolean |
escapeProcessing
Whether the escape processing is on or off.
|
protected int |
fetchDirection
The direction for fetching rows from database.
|
protected int |
fetchSize
The number of result set rows that is the default fetch size for
ResultSet objects generated from this
statement. |
static int |
MAX_ASYNC_QUERIES
Maximal number of queries executable in a single batch.
|
protected int |
maxFieldSize
The maximum number of bytes that can be returned for character and binary column values in a
ResultSet
object produced by this statement. |
protected int |
maxRows
The maximum number of rows that a
ResultSet object produced by this statement. |
protected int |
resultSetConcurrency
The result set concurrency for
ResultSet objects generated by this statement. |
protected int |
resultSetHoldability
The result set holdability for
ResultSet objects generated by this statement. |
protected int |
resultSetType
The result set type for
ResultSet objects generated by this statement. |
protected com.datastax.oss.driver.api.core.cql.Statement<?> |
statement
The Java Driver for Apache Cassandra® statement.
|
static String |
STATEMENTS_SEPARATOR_REGEX
CQL statements separator: semi-colon (
;). |
protected int |
updateCount
The update count.
|
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO| Modifier and Type | Method and Description |
|---|---|
void |
addBatch(String query) |
void |
cancel() |
protected void |
checkNotClosed()
Checks that the statement is not closed.
|
void |
clearBatch() |
void |
clearWarnings() |
void |
close() |
void |
closeOnCompletion() |
int |
compareTo(Object target) |
boolean |
execute(String query) |
boolean |
execute(String cql,
int autoGeneratedKeys) |
boolean |
execute(String cql,
int[] columnIndexes) |
boolean |
execute(String cql,
String[] columnNames) |
int[] |
executeBatch() |
ResultSet |
executeQuery(String cql) |
int |
executeUpdate(String cql)
Executes the given CQL statement, which may be an
INSERT, UPDATE, or DELETE statement or
a CQL statement that returns nothing, such as a CQL DDL statement. |
int |
executeUpdate(String cql,
int autoGeneratedKeys) |
int |
executeUpdate(String cql,
int[] columnIndexes) |
int |
executeUpdate(String cql,
String[] columnNames) |
CassandraConnection |
getCassandraConnection()
Retrieves the
CassandraConnection object that produced this Statement object. |
Connection |
getConnection() |
com.datastax.oss.driver.api.core.ConsistencyLevel |
getConsistencyLevel()
Gets the consistency level for the statement.
|
int |
getFetchDirection() |
int |
getFetchSize() |
ResultSet |
getGeneratedKeys() |
int |
getMaxFieldSize() |
int |
getMaxRows() |
boolean |
getMoreResults() |
boolean |
getMoreResults(int current) |
int |
getQueryTimeout()
Retrieves the number of seconds the driver will wait for a
Statement object to execute. |
ResultSet |
getResultSet() |
int |
getResultSetConcurrency() |
int |
getResultSetHoldability() |
int |
getResultSetType() |
int |
getUpdateCount() |
SQLWarning |
getWarnings() |
boolean |
isClosed() |
boolean |
isCloseOnCompletion() |
boolean |
isPoolable()
Returns a value indicating whether the
Statement is pool-able or not. |
boolean |
isWrapperFor(Class<?> iface) |
protected void |
resetResults()
Resets the current result set for this statement.
|
void |
setArray(int parameterIndex,
Array x) |
void |
setAsciiStream(int parameterIndex,
InputStream x) |
void |
setAsciiStream(int parameterIndex,
InputStream x,
int length) |
void |
setAsciiStream(int parameterIndex,
InputStream x,
long length) |
void |
setBinaryStream(int parameterIndex,
InputStream x) |
void |
setBinaryStream(int parameterIndex,
InputStream x,
int length) |
void |
setBinaryStream(int parameterIndex,
InputStream x,
long length) |
void |
setBlob(int parameterIndex,
InputStream inputStream,
long length) |
void |
setCharacterStream(int parameterIndex,
Reader reader) |
void |
setCharacterStream(int parameterIndex,
Reader reader,
long length) |
void |
setClob(int parameterIndex,
Clob x) |
void |
setClob(int parameterIndex,
Reader reader) |
void |
setClob(int parameterIndex,
Reader reader,
long length) |
void |
setConsistencyLevel(com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel)
Sets the consistency level for the statement.
|
void |
setCursorName(String name) |
void |
setEscapeProcessing(boolean enable) |
void |
setFetchDirection(int direction) |
void |
setFetchSize(int rows) |
void |
setMaxFieldSize(int max)
|
void |
setMaxRows(int max)
|
void |
setNCharacterStream(int parameterIndex,
Reader value) |
void |
setNCharacterStream(int parameterIndex,
Reader value,
long length) |
void |
setNClob(int parameterIndex,
NClob value) |
void |
setNClob(int parameterIndex,
Reader reader) |
void |
setNClob(int parameterIndex,
Reader reader,
long length) |
void |
setPoolable(boolean poolable)
Requests that a
Statement be pooled or not pooled. |
void |
setQueryTimeout(int seconds)
Sets the number of seconds the driver will wait for a
Statement object to execute. |
void |
setRef(int parameterIndex,
Ref x) |
void |
setSQLXML(int parameterIndex,
SQLXML xmlObject) |
void |
setUnicodeStream(int parameterIndex,
InputStream x,
int length) |
<T> T |
unwrap(Class<T> iface) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcancel, closeOnCompletion, execute, execute, executeLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeUpdate, executeUpdate, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, isCloseOnCompletion, setCursorName, setLargeMaxRowsisWrapperFor, unwrappublic static final int MAX_ASYNC_QUERIES
public static final String STATEMENTS_SEPARATOR_REGEX
;).protected static final int DEFAULT_FETCH_SIZE
protected CassandraConnection connection
protected String cql
protected ArrayList<String> batchQueries
protected int fetchDirection
ResultSet.FETCH_FORWARD.protected int fetchSize
ResultSet objects generated from this
statement.protected int maxFieldSize
ResultSet
object produced by this statement. By default, there is no limit (0).protected int maxRows
ResultSet object produced by this statement. By default, there is no
limit (0).protected int resultSetType
ResultSet objects generated by this statement.protected int resultSetConcurrency
ResultSet objects generated by this statement.protected int resultSetHoldability
ResultSet objects generated by this statement.protected ResultSet currentResultSet
protected int updateCount
protected boolean escapeProcessing
protected com.datastax.oss.driver.api.core.cql.Statement<?> statement
protected com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel
public void addBatch(String query) throws SQLException
addBatch in interface StatementSQLExceptionprotected final void checkNotClosed()
throws SQLException
SQLException - when something went wrong during the checking of the statement status.SQLRecoverableException - when a method has been called on a closed statement.public void clearBatch()
throws SQLException
clearBatch in interface StatementSQLExceptionpublic void clearWarnings()
throws SQLException
clearWarnings in interface StatementSQLExceptionpublic void close()
close in interface AutoCloseableclose in interface Statementpublic int compareTo(@Nonnull Object target)
compareTo in interface Comparable<Object>public boolean execute(String query) throws SQLException
execute in interface StatementSQLExceptionpublic boolean execute(String cql, int autoGeneratedKeys) throws SQLException
execute in interface StatementSQLExceptionpublic int[] executeBatch()
throws SQLException
executeBatch in interface StatementSQLExceptionpublic ResultSet executeQuery(String cql) throws SQLException
executeQuery in interface StatementSQLExceptionpublic int executeUpdate(String cql) throws SQLException
INSERT, UPDATE, or DELETE statement or
a CQL statement that returns nothing, such as a CQL DDL statement.
Note: This method cannot be called on a PreparedStatement or CallableStatement.
executeUpdate in interface Statementcql - A CQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE, or
DELETE; or a CQL statement that returns nothing, such as a DDL statement.SQLException - when something went wrong during the execution of the statement.public int executeUpdate(String cql, int autoGeneratedKeys) throws SQLException
executeUpdate in interface StatementSQLExceptionpublic Connection getConnection() throws SQLException
getConnection in interface StatementSQLExceptionpublic CassandraConnection getCassandraConnection() throws SQLException
CassandraConnection object that produced this Statement object.SQLException - if a database access error occurs or this method is called on a closed Statement.public com.datastax.oss.driver.api.core.ConsistencyLevel getConsistencyLevel()
CassandraStatementExtrasSee consistency level documentation for further details.
getConsistencyLevel in interface CassandraStatementExtraspublic void setConsistencyLevel(com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel)
CassandraStatementExtrasSee consistency level documentation for further details.
setConsistencyLevel in interface CassandraStatementExtrasconsistencyLevel - The consistency level to use for this statement.public int getFetchDirection()
throws SQLException
getFetchDirection in interface StatementSQLExceptionpublic void setFetchDirection(int direction)
throws SQLException
setFetchDirection in interface StatementSQLExceptionpublic int getFetchSize()
throws SQLException
getFetchSize in interface StatementSQLExceptionpublic void setFetchSize(int rows)
throws SQLException
setFetchSize in interface StatementSQLExceptionpublic int getMaxFieldSize()
throws SQLException
getMaxFieldSize in interface StatementSQLExceptionpublic void setMaxFieldSize(int max)
throws SQLException
ResultSet object produced by this Statement object.
This setting is silently ignored. There is no such limit, so maxFieldSize is always 0.
setMaxFieldSize in interface Statementmax - The new column size limit in bytes; zero means there is no limit.SQLException - if a database access error occurs or this method is called on a closed Statement.public int getMaxRows()
throws SQLException
getMaxRows in interface StatementSQLExceptionpublic void setMaxRows(int max)
throws SQLException
ResultSet object generated by this
Statement object can contain to the given number. If the limit is exceeded, the excess rows are silently
dropped.
This setting is silently ignored. There is no such limit, so maxRows is always 0.
setMaxRows in interface Statementmax - The new max rows limit; zero means there is no limit.SQLException - if a database access error occurs or this method is called on a closed Statement.public boolean getMoreResults()
throws SQLException
getMoreResults in interface StatementSQLExceptionpublic boolean getMoreResults(int current)
throws SQLException
getMoreResults in interface StatementSQLExceptionpublic int getQueryTimeout()
throws SQLException
Statement object to execute. If the limit is
exceeded, a SQLException is thrown.getQueryTimeout in interface StatementSQLException - if a database access error occurs or this method is called on a closed Statement.public void setQueryTimeout(int seconds)
throws SQLException
Statement object to execute.
Modifying this setting will derive the default execution profile of the driver configuration by updating the
parameter basic.request.timeout and apply this specific execution profile to this statement ONLY. Later
statements will use the request timeout globally configured for the session.
setQueryTimeout in interface Statementseconds - The new query timeout limit in seconds; zero means there is no limit.SQLException - if a database access error occurs, this method is called on a closed Statement.public ResultSet getResultSet() throws SQLException
getResultSet in interface StatementSQLExceptionpublic int getResultSetConcurrency()
throws SQLException
getResultSetConcurrency in interface StatementSQLExceptionpublic int getResultSetHoldability()
throws SQLException
getResultSetHoldability in interface StatementSQLExceptionpublic int getResultSetType()
throws SQLException
getResultSetType in interface StatementSQLExceptionpublic int getUpdateCount()
throws SQLException
getUpdateCount in interface StatementSQLExceptionpublic SQLWarning getWarnings() throws SQLException
getWarnings in interface StatementSQLExceptionpublic boolean isPoolable()
throws SQLException
Statement is pool-able or not.isPoolable in interface Statementfalse.SQLException - if this method is called on a closed Statement.public void setPoolable(boolean poolable)
throws SQLException
Statement be pooled or not pooled.
This setting is silently ignored. The CassandraStatement are never pool-able.
setPoolable in interface Statementpoolable - Requests that the statement be pooled if true and that the statement not be pooled if
false.SQLException - if this method is called on a closed Statement.protected final void resetResults()
public void setEscapeProcessing(boolean enable)
throws SQLException
setEscapeProcessing in interface StatementSQLExceptionpublic void cancel()
throws SQLException
SQLExceptionpublic boolean execute(String cql, int[] columnIndexes) throws SQLException
SQLExceptionpublic boolean execute(String cql, String[] columnNames) throws SQLException
SQLExceptionpublic int executeUpdate(String cql, int[] columnIndexes) throws SQLException
SQLExceptionpublic int executeUpdate(String cql, String[] columnNames) throws SQLException
SQLExceptionpublic ResultSet getGeneratedKeys() throws SQLException
SQLExceptionpublic void setCursorName(String name) throws SQLException
SQLExceptionpublic void closeOnCompletion()
throws SQLException
SQLExceptionpublic boolean isCloseOnCompletion()
throws SQLException
SQLExceptionpublic void setArray(int parameterIndex,
Array x)
throws SQLException
SQLExceptionpublic void setAsciiStream(int parameterIndex,
InputStream x)
throws SQLException
SQLExceptionpublic void setAsciiStream(int parameterIndex,
InputStream x,
int length)
throws SQLException
SQLExceptionpublic void setAsciiStream(int parameterIndex,
InputStream x,
long length)
throws SQLException
SQLExceptionpublic void setBinaryStream(int parameterIndex,
InputStream x)
throws SQLException
SQLExceptionpublic void setBinaryStream(int parameterIndex,
InputStream x,
int length)
throws SQLException
SQLExceptionpublic void setBinaryStream(int parameterIndex,
InputStream x,
long length)
throws SQLException
SQLExceptionpublic void setBlob(int parameterIndex,
InputStream inputStream,
long length)
throws SQLException
SQLExceptionpublic void setCharacterStream(int parameterIndex,
Reader reader)
throws SQLException
SQLExceptionpublic void setCharacterStream(int parameterIndex,
Reader reader,
long length)
throws SQLException
SQLExceptionpublic void setClob(int parameterIndex,
Clob x)
throws SQLException
SQLExceptionpublic void setClob(int parameterIndex,
Reader reader)
throws SQLException
SQLExceptionpublic void setClob(int parameterIndex,
Reader reader,
long length)
throws SQLException
SQLExceptionpublic void setNCharacterStream(int parameterIndex,
Reader value)
throws SQLException
SQLExceptionpublic void setNCharacterStream(int parameterIndex,
Reader value,
long length)
throws SQLException
SQLExceptionpublic void setNClob(int parameterIndex,
NClob value)
throws SQLException
SQLExceptionpublic void setNClob(int parameterIndex,
Reader reader)
throws SQLException
SQLExceptionpublic void setNClob(int parameterIndex,
Reader reader,
long length)
throws SQLException
SQLExceptionpublic void setRef(int parameterIndex,
Ref x)
throws SQLException
SQLExceptionpublic void setSQLXML(int parameterIndex,
SQLXML xmlObject)
throws SQLException
SQLExceptionpublic void setUnicodeStream(int parameterIndex,
InputStream x,
int length)
throws SQLException
SQLExceptionpublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor in interface WrapperSQLExceptionpublic <T> T unwrap(Class<T> iface) throws SQLException
unwrap in interface WrapperSQLExceptionCopyright © 2020–2024 ING Bank. All rights reserved.