public class CassandraConnection extends Object implements Connection
Connection to create a JDBC connection to a Cassandra
cluster.| Modifier and Type | Field and Description |
|---|---|
static int |
dbMajorVersion
Minimal Apache Cassandra major version supported by the Java Driver for Apache Cassandra®.
|
static int |
dbMinorVersion
Minimal Apache Cassandra minor version supported by the Java Driver for Apache Cassandra®.
|
static int |
dbPatchVersion
Minimal Apache Cassandra patch version supported by the Java Driver for Apache Cassandra®.
|
protected static int |
FALLBACK_FETCH_SIZE
The default fetch size when it's not configured neither in JDBC URL nor in a configuration file and the default
fetch size (request page size) cannot be retrieved from the configuration profile.
|
protected String |
url
The connection URL.
|
protected String |
username
The username used by the connection.
|
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE| Constructor and Description |
|---|
CassandraConnection(com.datastax.oss.driver.api.core.session.Session cSession,
String currentKeyspace,
com.datastax.oss.driver.api.core.ConsistencyLevel defaultConsistencyLevel,
boolean debugMode,
OptionSet optionSet,
String defaultExecutionProfile)
Instantiates a new JDBC connection to a Cassandra cluster using preexisting session.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort(Executor executor) |
void |
clearWarnings() |
void |
close() |
void |
commit() |
Array |
createArrayOf(String typeName,
Object[] elements) |
Blob |
createBlob() |
Clob |
createClob() |
NClob |
createNClob() |
SQLXML |
createSQLXML() |
Statement |
createStatement() |
Statement |
createStatement(int resultSetType,
int resultSetConcurrency) |
Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
Struct |
createStruct(String typeName,
Object[] attributes) |
com.datastax.oss.driver.api.core.config.DriverExecutionProfile |
getActiveExecutionProfile()
Gets the active execution profile.
|
boolean |
getAutoCommit() |
String |
getCatalog() |
Properties |
getClientInfo() |
String |
getClientInfo(String label) |
com.datastax.oss.driver.api.core.metadata.Metadata |
getClusterMetadata()
Gets the metadata of the Cassandra cluster used by this connection.
|
Properties |
getConnectionProperties()
Gets a
Properties object listing the properties of this connection. |
com.datastax.oss.driver.api.core.ConsistencyLevel |
getConsistencyLevel()
Gets the consistency level currently applied to this connection.
|
int |
getDefaultFetchSize()
Gets the default fetch size applied to this connection.
|
int |
getHoldability() |
DatabaseMetaData |
getMetaData() |
int |
getNetworkTimeout() |
OptionSet |
getOptionSet()
Gets the compliance mode option set used for the connection.
|
String |
getSchema() |
com.datastax.oss.driver.api.core.session.Session |
getSession()
Gets the CQL session used to send requests to the Cassandra cluster.
|
int |
getTransactionIsolation() |
Map<String,Class<?>> |
getTypeMap() |
SQLWarning |
getWarnings() |
boolean |
isClosed() |
boolean |
isDebugMode()
Gets whether the debug mode is active on this connection.
|
boolean |
isReadOnly() |
boolean |
isValid(int timeout) |
boolean |
isWrapperFor(Class<?> iface) |
String |
nativeSQL(String sql) |
CallableStatement |
prepareCall(String cql) |
CallableStatement |
prepareCall(String cql,
int resultSetType,
int resultSetConcurrency) |
CallableStatement |
prepareCall(String cql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
CassandraPreparedStatement |
prepareStatement(String cql) |
PreparedStatement |
prepareStatement(String cql,
int autoGeneratedKeys) |
PreparedStatement |
prepareStatement(String cql,
int[] columnIndexes) |
CassandraPreparedStatement |
prepareStatement(String cql,
int resultSetType,
int resultSetConcurrency) |
CassandraPreparedStatement |
prepareStatement(String cql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
PreparedStatement |
prepareStatement(String cql,
String[] columnNames) |
void |
releaseSavepoint(Savepoint savepoint) |
protected boolean |
removeStatement(Statement statement)
Removes a statement from the open statements list.
|
void |
restoreLastExecutionProfile()
Restores the last execution profile defined before switching it.
|
void |
rollback() |
void |
rollback(Savepoint savepoint) |
void |
setActiveExecutionProfile(String profile)
Sets a new execution profile for the current connection.
|
void |
setAutoCommit(boolean autoCommit) |
void |
setCatalog(String catalog) |
void |
setClientInfo(Properties properties) |
void |
setClientInfo(String key,
String value) |
void |
setConsistencyLevel(com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel)
Sets the consistency level applied to this connection.
|
void |
setHoldability(int holdability) |
void |
setNetworkTimeout(Executor executor,
int milliseconds) |
void |
setReadOnly(boolean readOnly) |
Savepoint |
setSavepoint() |
Savepoint |
setSavepoint(String name) |
void |
setSchema(String schema) |
void |
setTransactionIsolation(int level) |
void |
setTypeMap(Map<String,Class<?>> map) |
String |
toString() |
<T> T |
unwrap(Class<T> iface) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitabort, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStruct, getNetworkTimeout, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, setNetworkTimeout, setSavepoint, setSavepoint, setTypeMapisWrapperFor, unwrappublic static volatile int dbMajorVersion
public static volatile int dbMinorVersion
public static volatile int dbPatchVersion
protected static final int FALLBACK_FETCH_SIZE
protected String username
protected String url
public CassandraConnection(com.datastax.oss.driver.api.core.session.Session cSession,
String currentKeyspace,
com.datastax.oss.driver.api.core.ConsistencyLevel defaultConsistencyLevel,
boolean debugMode,
OptionSet optionSet,
String defaultExecutionProfile)
cSession - The session to use.currentKeyspace - The keyspace to use.defaultConsistencyLevel - The default consistency level.debugMode - Debug mode flag.optionSet - The compliance mode option set to use.defaultExecutionProfile - The name of the default execution profile to use.public void clearWarnings()
throws SQLException
clearWarnings in interface ConnectionSQLExceptionpublic void close()
throws SQLException
close in interface AutoCloseableclose in interface ConnectionSQLExceptionpublic void commit()
throws SQLException
commit in interface ConnectionSQLExceptionpublic Statement createStatement() throws SQLException
createStatement in interface ConnectionSQLExceptionpublic Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
createStatement in interface ConnectionSQLExceptionpublic Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
createStatement in interface ConnectionSQLExceptionpublic boolean getAutoCommit()
throws SQLException
getAutoCommit in interface ConnectionSQLExceptionpublic void setAutoCommit(boolean autoCommit)
throws SQLException
setAutoCommit in interface ConnectionSQLExceptionpublic String getCatalog() throws SQLException
getCatalog in interface ConnectionSQLExceptionpublic void setCatalog(String catalog) throws SQLException
setCatalog in interface ConnectionSQLExceptionpublic Properties getConnectionProperties()
Properties object listing the properties of this connection.public Properties getClientInfo() throws SQLException
getClientInfo in interface ConnectionSQLExceptionpublic String getClientInfo(String label) throws SQLException
getClientInfo in interface ConnectionSQLExceptionpublic void setClientInfo(Properties properties)
setClientInfo in interface Connectionpublic void setClientInfo(String key, String value)
setClientInfo in interface Connectionpublic com.datastax.oss.driver.api.core.metadata.Metadata getClusterMetadata()
public boolean isDebugMode()
true if the debug mode is active on this connection, false otherwise.public com.datastax.oss.driver.api.core.ConsistencyLevel getConsistencyLevel()
public void setConsistencyLevel(com.datastax.oss.driver.api.core.ConsistencyLevel consistencyLevel)
consistencyLevel - The consistency level to apply to this connection.public int getDefaultFetchSize()
public int getHoldability()
throws SQLException
getHoldability in interface ConnectionSQLExceptionpublic void setHoldability(int holdability)
throws SQLException
setHoldability in interface ConnectionSQLExceptionpublic DatabaseMetaData getMetaData() throws SQLException
getMetaData in interface ConnectionSQLExceptionpublic String getSchema() throws SQLException
getSchema in interface ConnectionSQLExceptionpublic void setSchema(String schema) throws SQLException
setSchema in interface ConnectionSQLExceptionpublic com.datastax.oss.driver.api.core.session.Session getSession()
public int getTransactionIsolation()
throws SQLException
getTransactionIsolation in interface ConnectionSQLExceptionpublic void setTransactionIsolation(int level)
throws SQLException
setTransactionIsolation in interface ConnectionSQLExceptionpublic Map<String,Class<?>> getTypeMap() throws SQLException
getTypeMap in interface ConnectionSQLExceptionpublic SQLWarning getWarnings() throws SQLException
getWarnings in interface ConnectionSQLExceptionpublic boolean isClosed()
throws SQLException
isClosed in interface ConnectionSQLExceptionpublic boolean isReadOnly()
throws SQLException
isReadOnly in interface ConnectionSQLExceptionpublic void setReadOnly(boolean readOnly)
throws SQLException
setReadOnly in interface ConnectionSQLExceptionpublic boolean isValid(int timeout)
throws SQLTimeoutException
isValid in interface ConnectionSQLTimeoutExceptionpublic String nativeSQL(String sql) throws SQLException
nativeSQL in interface ConnectionSQLExceptionpublic CassandraPreparedStatement prepareStatement(String cql) throws SQLException
prepareStatement in interface ConnectionSQLExceptionpublic CassandraPreparedStatement prepareStatement(String cql, int resultSetType, int resultSetConcurrency) throws SQLException
prepareStatement in interface ConnectionSQLExceptionpublic CassandraPreparedStatement prepareStatement(String cql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
prepareStatement in interface ConnectionSQLExceptionpublic void rollback()
throws SQLException
rollback in interface ConnectionSQLExceptionprotected boolean removeStatement(Statement statement)
statement - The statement.true if the statement has successfully been removed, false otherwise.public OptionSet getOptionSet()
public com.datastax.oss.driver.api.core.config.DriverExecutionProfile getActiveExecutionProfile()
public void setActiveExecutionProfile(String profile)
If the given profile name is invalid, this method has no effect.
profile - The execution profile to set.public void restoreLastExecutionProfile()
If the execution profile has never been changed previously, this method has no effect.
public Array createArrayOf(String typeName, Object[] elements) throws SQLException
SQLExceptionpublic Blob createBlob() throws SQLException
SQLExceptionpublic Clob createClob() throws SQLException
SQLExceptionpublic NClob createNClob() throws SQLException
SQLExceptionpublic SQLXML createSQLXML() throws SQLException
SQLExceptionpublic Struct createStruct(String typeName, Object[] attributes) throws SQLException
SQLExceptionpublic CallableStatement prepareCall(String cql) throws SQLException
SQLExceptionpublic CallableStatement prepareCall(String cql, int resultSetType, int resultSetConcurrency) throws SQLException
SQLExceptionpublic CallableStatement prepareCall(String cql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
SQLExceptionpublic PreparedStatement prepareStatement(String cql, int autoGeneratedKeys) throws SQLException
SQLExceptionpublic PreparedStatement prepareStatement(String cql, int[] columnIndexes) throws SQLException
SQLExceptionpublic PreparedStatement prepareStatement(String cql, String[] columnNames) throws SQLException
SQLExceptionpublic void releaseSavepoint(Savepoint savepoint) throws SQLException
SQLExceptionpublic void rollback(Savepoint savepoint) throws SQLException
SQLExceptionpublic Savepoint setSavepoint() throws SQLException
SQLExceptionpublic Savepoint setSavepoint(String name) throws SQLException
SQLExceptionpublic void setTypeMap(Map<String,Class<?>> map) throws SQLException
SQLExceptionpublic void abort(Executor executor) throws SQLException
SQLExceptionpublic void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
SQLExceptionpublic int getNetworkTimeout()
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.