public class CassandraDataSource extends Object implements ConnectionPoolDataSource, DataSource
DataSource and ConnectionPoolDataSource.| Modifier and Type | Field and Description |
|---|---|
protected static String |
DATA_SOURCE_DESCRIPTION
The Cassandra data source description.
|
| Constructor and Description |
|---|
CassandraDataSource(List<ContactPoint> contactPoints,
String keyspace)
Constructor.
|
CassandraDataSource(List<ContactPoint> contactPoints,
String keyspace,
String user,
String password,
String consistency)
Deprecated.
Use
CassandraDataSource(List, String) and specific setters instead. This constructor will
be removed in a future release. |
CassandraDataSource(List<ContactPoint> contactPoints,
String keyspace,
String user,
String password,
String consistency,
String localDataCenter)
Deprecated.
Use
CassandraDataSource(List, String) and specific setters instead. This constructor will
be removed in a future release. |
| Modifier and Type | Method and Description |
|---|---|
String |
getActiveProfile()
Gets the execution profile to use when the connection is created.
|
String |
getAstraDatabaseName()
Gets the AstraDB database name.
|
String |
getAstraRegion()
Gets the region of the AstraDB instance.
|
String |
getAwsRegion()
Gets the AWS region of the contact point of the Amazon Keyspaces instance.
|
String |
getAwsSecretName()
Gets the name of the secret, stored in Amazon Secret Manager, containing the credentials of the user used for
the connection.
|
String |
getAwsSecretRegion()
Gets the AWS region of the Amazon Secret Manager in which the credentials of the user used for the connection
are stored.
|
String |
getComplianceMode()
Gets the compliance mode.
|
String |
getConfigurationFile()
Gets the fully qualified path of the
client configuration file used for the created connection.
|
CassandraConnection |
getConnection() |
CassandraConnection |
getConnection(String user,
String password) |
Long |
getConnectionTimeout()
Gets the connection timeout in milliseconds.
|
String |
getConsistency()
Gets the consistency level.
|
List<ContactPoint> |
getContactPoints()
Gets the contact points of the data source.
|
String |
getDatabaseName()
Gets the database name.
|
String |
getDescription()
Gets the data source description.
|
Integer |
getFetchSize()
Gets the default fetch size for all the queries returning result sets.
|
String |
getLoadBalancingPolicy()
Gets the load balancing policy.
|
String |
getLocalDataCenter()
Gets the local datacenter.
|
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Logger |
getParentLogger() |
String |
getPassword()
Gets the password used to connect to the data source.
|
PooledCassandraConnection |
getPooledConnection() |
PooledCassandraConnection |
getPooledConnection(String user,
String password) |
String |
getReconnectionPolicy()
Gets the reconnection policy.
|
Long |
getRequestTimeout()
Gets the request timeout in milliseconds.
|
String |
getRetryPolicy()
Gets the retry policy.
|
String |
getSecureConnectBundle()
Gets the fully qualified path of the cloud secure connect bundle file used to connect to an AstraDB instance.
|
String |
getSerialConsistency()
Gets the serial consistency level.
|
String |
getSslEngineFactory()
Gets the SSL engine factory.
|
String |
getToken()
Gets the token used to connect to an AstraDB instance.
|
String |
getUser()
Gets the username used to connect to the data source.
|
boolean |
isHostnameVerified()
Gets whether the validation of the server certificate's common name against the hostname of the server being
connected to is enabled.
|
boolean |
isKerberosAuthProviderEnabled()
Gets whether the Kerberos auth provider is enabled.
|
boolean |
isSigV4AuthProviderEnabled()
Gets whether the Amazon Signature V4 auth provider is enabled.
|
boolean |
isSslEnabled()
Gets whether the secured traffic is enabled for the created connection.
|
boolean |
isTcpKeepAliveEnabled()
Gets whether the TCP keep-alive is enabled.
|
boolean |
isTcpNoDelayEnabled()
Gets whether the Nagle's algorithm is enabled.
|
boolean |
isWrapperFor(Class<?> iface) |
void |
setActiveProfile(String profile)
Sets the execution profile to use when the connection is created.
|
void |
setAstraDatabaseName(String astraDatabaseName)
Sets the AstraDB database name.
|
void |
setAstraRegion(String region)
Sets the region of the AstraDB instance.
|
void |
setAwsRegion(software.amazon.awssdk.regions.Region region)
Sets the AWS region of the contact point of the Amazon Keyspaces instance.
|
void |
setAwsRegion(String region)
Sets the AWS region of the contact point of the Amazon Keyspaces instance.
|
void |
setAwsSecretName(String secretName)
Sets the name of the secret, stored in Amazon Secret Manager, containing the credentials of the user used for
the connection.
|
void |
setAwsSecretRegion(software.amazon.awssdk.regions.Region region)
Sets the AWS region of the Amazon Secret Manager in which the credentials of the user used for the connection
are stored.
|
void |
setAwsSecretRegion(String region)
Sets the AWS region of the Amazon Secret Manager in which the credentials of the user used for the connection
are stored.
|
void |
setComplianceMode(String complianceMode)
Sets the compliance mode.
|
void |
setConfigurationFile(Path configurationFilePath)
Sets the path of the
client configuration fileused for the created connection.
|
void |
setConfigurationFile(String configurationFile)
Sets the fully qualified path of the
client configuration file used for the created connection.
|
void |
setConnectionTimeout(Long timeout)
Sets the connection timeout in milliseconds.
|
void |
setConsistency(String consistency)
Sets the consistency level.
|
void |
setContactPoints(List<ContactPoint> contactPoints)
Sets the contact points of the data source.
|
void |
setDatabaseName(String databaseName)
Sets the database name.
|
void |
setFetchSize(Integer fetchSize)
Sets the default fetch size for all the queries returning result sets.
|
void |
setHostnameVerified(boolean enabled)
Sets whether the validation of the server certificate's common name against the hostname of the server being
connected to is enabled.
|
void |
setKerberosAuthProviderEnabled(boolean enabled)
Sets whether the Kerberos auth provider is enabled.
|
void |
setLoadBalancingPolicy(String policy)
Sets the load balancing policy.
|
void |
setLocalDataCenter(String localDataCenter)
Sets the local datacenter.
|
void |
setLoginTimeout(int timeout) |
void |
setLogWriter(PrintWriter writer) |
void |
setPassword(String password)
Sets the password used to connect to the data source.
|
void |
setReconnectionPolicy(String policy)
Sets the reconnection policy.
|
void |
setRequestTimeout(Long timeout)
Sets the request timeout in milliseconds.
|
void |
setRetryPolicy(String policy)
Sets the retry policy.
|
void |
setSecureConnectBundle(Path bundlePath)
Sets the path of the cloud secure connect bundle file used to connect to an AstraDB instance.
|
void |
setSecureConnectBundle(String bundlePath)
Sets the fully qualified path of the cloud secure connect bundle file used to connect to an AstraDB instance.
|
void |
setSerialConsistency(String consistency)
Sets the serial consistency level.
|
void |
setSigV4AuthProviderEnabled(boolean enabled)
Sets whether the Amazon Signature V4 auth provider is enabled.
|
void |
setSslEnabled(boolean enabled)
Sets whether the secured traffic is enabled for the created connection.
|
void |
setSslEngineFactory(String factory)
Sets the SSL engine factory.
|
void |
setTcpKeepAliveEnabled(boolean enabled)
Sets whether the TCP keep-alive is enabled.
|
void |
setTcpNoDelayEnabled(boolean enabled)
Sets whether the Nagle's algorithm is enabled.
|
void |
setToken(String token)
Sets the token used to connect to an AstraDB instance.
|
void |
setURL(String url)
Sets the
DriverManager URL used to establish the connection. |
void |
setUser(String user)
Sets the username used to connect to the data source.
|
<T> T |
unwrap(Class<T> iface) |
protected static final String DATA_SOURCE_DESCRIPTION
public CassandraDataSource(List<ContactPoint> contactPoints, String keyspace)
contactPoints - The contact points.keyspace - The keyspace.@Deprecated public CassandraDataSource(List<ContactPoint> contactPoints, String keyspace, String user, String password, String consistency)
CassandraDataSource(List, String) and specific setters instead. This constructor will
be removed in a future release.contactPoints - The contact points.keyspace - The keyspace.user - The username used to connect.password - The password used to connect.consistency - The consistency level.@Deprecated public CassandraDataSource(List<ContactPoint> contactPoints, String keyspace, String user, String password, String consistency, String localDataCenter)
CassandraDataSource(List, String) and specific setters instead. This constructor will
be removed in a future release.DefaultLoadBalancingPolicy).contactPoints - The contact points.keyspace - The keyspace.user - The username used to connect.password - The password used to connect.consistency - The consistency level.localDataCenter - The local datacenter.public CassandraConnection getConnection() throws SQLException
getConnection in interface DataSourceSQLExceptionpublic CassandraConnection getConnection(String user, String password) throws SQLException
getConnection in interface DataSourceSQLExceptionpublic int getLoginTimeout()
getLoginTimeout in interface CommonDataSourcepublic PrintWriter getLogWriter()
getLogWriter in interface CommonDataSourcepublic void setLoginTimeout(int timeout)
setLoginTimeout in interface CommonDataSourcepublic void setLogWriter(PrintWriter writer)
setLogWriter in interface CommonDataSourcepublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor in interface WrapperSQLExceptionpublic <T> T unwrap(Class<T> iface) throws SQLException
unwrap in interface WrapperSQLExceptionpublic Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface CommonDataSourceSQLFeatureNotSupportedExceptionpublic PooledCassandraConnection getPooledConnection() throws SQLException
getPooledConnection in interface ConnectionPoolDataSourceSQLExceptionpublic PooledCassandraConnection getPooledConnection(String user, String password) throws SQLException
getPooledConnection in interface ConnectionPoolDataSourceSQLExceptionpublic void setURL(String url)
DriverManager URL used to establish the connection.url - The DriverManager URL used to establish the connection.public String getDescription()
public List<ContactPoint> getContactPoints()
public void setContactPoints(List<ContactPoint> contactPoints)
contactPoints - The contact points of the data source.public String getAstraDatabaseName()
public void setAstraDatabaseName(String astraDatabaseName)
astraDatabaseName - The AstraDB database name.public String getDatabaseName()
Warning: for connections to AstraDB instances, the database name must be retrieved with
getAstraDatabaseName().
public void setDatabaseName(String databaseName)
Warning: for connections to AstraDB instances, the database name must be set with
setAstraDatabaseName(String).
databaseName - The database name. In case of Cassandra, i.e. the keyspace used as data source.public String getPassword()
public void setPassword(String password)
password - The password used to connect to the data source.public String getUser()
public void setUser(String user)
user - The username used to connect to the data source.public String getComplianceMode()
The default value is Default.
Liquibase).public void setComplianceMode(String complianceMode)
complianceMode - The compliance mode to use for the connection (for example, Liquibase).public String getConsistency()
See
consistency level documentation for further details. The default consistency level is
ConsistencyLevel.LOCAL_ONE.
public void setConsistency(String consistency)
See
consistency level documentation and ConsistencyLevel to get the acceptable values.
consistency - The consistency level.public String getSerialConsistency()
See
serial consistency level documentation for further details. The default serial consistency level is
ConsistencyLevel.SERIAL.
public void setSerialConsistency(String consistency)
The acceptable values are ConsistencyLevel.SERIAL and ConsistencyLevel.LOCAL_SERIAL. See
serial consistency level documentation for further details.
consistency - The serial consistency level.public String getLocalDataCenter()
DefaultLoadBalancingPolicy.public void setLocalDataCenter(String localDataCenter)
DefaultLoadBalancingPolicy.localDataCenter - The local datacenter.public String getActiveProfile()
The default value is DriverExecutionProfile.DEFAULT_NAME.
public void setActiveProfile(String profile)
profile - The execution profile to use for the connection.public String getRetryPolicy()
The value must be the full package of a policy's class implementing RetryPolicy interface.
By default, the driver will use DefaultRetryPolicy (see
Retries documentation).
public void setRetryPolicy(String policy)
The value must be the full package of a policy's class implementing RetryPolicy interface.
See
Retries documentation for further information.
policy - The retry policy.public String getLoadBalancingPolicy()
The value must be the full package of a policy's class implementing LoadBalancingPolicy interface.
By default, the driver will use DefaultLoadBalancingPolicy (see
Load balancing documentation).
public void setLoadBalancingPolicy(String policy)
The value must be the full package of a policy's class implementing LoadBalancingPolicy interface.
See
Load balancing documentation for further information.
policy - The load balancing policy.public String getReconnectionPolicy()
The default value is ExponentialReconnectionPolicy with default values (see
Reconnection documentation).
public void setReconnectionPolicy(String policy)
If you want to define a custom base delay (in seconds, by default 1 second) and a custom max delay
(in seconds, by default 60 seconds) for the default ExponentialReconnectionPolicy, you can specify
it as following: ExponentialReconnectionPolicy((long)<delay>,(long)<maxDelay>).
You can also use the ConstantReconnectionPolicy as policy using ConstantReconnectionPolicy()
or with a custom base delay (in seconds, by default 1 second):
ConstantReconnectionPolicy((long)<baseDelay>).
Make sure you always cast the policy's arguments appropriately.
If you want to use a custom policy, specify the full package of the policy's class.
See Reconnection documentation for further information.
policy - The reconnection policy.public Integer getFetchSize()
This value is the number of rows the server will return in each network frame. It corresponds to the
property datastax-java-driver.basic.request.page-size. See the documentation about the
paging for
further details.
The default value is .
public void setFetchSize(Integer fetchSize)
This value is the number of rows the server will return in each network frame. It corresponds to the
property datastax-java-driver.basic.request.page-size. See the documentation about the
paging for
further details.
fetchSize - The fetch size.public boolean isSslEnabled()
true if the secured traffic is enabled, false otherwise.public void setSslEnabled(boolean enabled)
When enabled, the default SSL engine DefaultSslEngineFactory is used with the JSSE system properties
defined for your application.
enabled - Whether the secured traffic is enabled.public String getSslEngineFactory()
The default value is DefaultSslEngineFactory.
public void setSslEngineFactory(String factory)
The value must be the fully-qualified name of a class with a no-args constructor implementing
SslEngineFactory interface.
factory - The SSL engine factory.public boolean isHostnameVerified()
The default value is true when the DefaultSslEngineFactory is used.
true if the hostname verification is enabled, false otherwise.public void setHostnameVerified(boolean enabled)
enabled - Whether the hostname verification is enabled.public String getSecureConnectBundle()
public void setSecureConnectBundle(String bundlePath)
bundlePath - The fully qualified path of the cloud secure connect bundle file.public void setSecureConnectBundle(Path bundlePath)
bundlePath - The path of the cloud secure connect bundle file.public String getToken()
public void setToken(String token)
token - The token.public String getAstraRegion()
public void setAstraRegion(String region)
region - The AstraDB region.public boolean isKerberosAuthProviderEnabled()
The default value is false.
See
Authentication reference and
Kerberos authenticator for Java driver for further information.
true if the Kerberos auth provider is enabled, false otherwise.public void setKerberosAuthProviderEnabled(boolean enabled)
This will enable the Kerberos AuthProvider implementation for the connection with default parameters.
See
Authentication reference and
Kerberos authenticator for Java driver for further information.
enabled - Whether the Kerberos auth provider is enabled.public Long getRequestTimeout()
It corresponds to the property basic.request.timeout in the
Configuration reference page.
The default value is 2 seconds.
public void setRequestTimeout(Long timeout)
It corresponds to the property basic.request.timeout in the
Configuration reference page.
timeout - The request timeout in milliseconds.public Long getConnectionTimeout()
It corresponds to the property advanced.connection.connect-timeout in the
Configuration reference page.
The default value is 5 seconds.
public void setConnectionTimeout(Long timeout)
It corresponds to the property advanced.connection.connect-timeout in the
Configuration reference page.
timeout - The connection timeout in milliseconds.public boolean isTcpNoDelayEnabled()
It corresponds to the property advanced.socket.tcp-no-delay in the
Configuration reference page.
The default value is true.
true if the Nagle's algorithm is enabled, false otherwise.public void setTcpNoDelayEnabled(boolean enabled)
It corresponds to the property advanced.socket.tcp-no-delay in the
Configuration reference page.
enabled - Whether the Nagle's algorithm is enabled.public boolean isTcpKeepAliveEnabled()
It corresponds to the property advanced.socket.keep-alive in the
Configuration reference page.
The default value is false.
true if the TCP keep-alive is enabled, false otherwise.public void setTcpKeepAliveEnabled(boolean enabled)
It corresponds to the property advanced.socket.keep-alive in the
Configuration reference page.
enabled - Whether the TCP keep-alive is enabled.public String getConfigurationFile()
public void setConfigurationFile(String configurationFile)
configurationFile - The fully qualified path of the client configuration file.public void setConfigurationFile(Path configurationFilePath)
configurationFilePath - The path of the client configuration file.public String getAwsRegion()
public void setAwsRegion(String region)
region - The string representation of the region.public void setAwsRegion(software.amazon.awssdk.regions.Region region)
region - The AWS region.public String getAwsSecretRegion()
getAwsRegion().public void setAwsSecretRegion(String region)
region - The string representation of the region.public void setAwsSecretRegion(software.amazon.awssdk.regions.Region region)
region - The AWS region.public String getAwsSecretName()
public void setAwsSecretName(String secretName)
secretName - The name of the secret.public boolean isSigV4AuthProviderEnabled()
The default value is false.
See
Authentication reference and
Amazon Signature V4 authenticator plugin for Java driver for further information.
true if the Amazon Signature V4 auth provider is enabled, false otherwise.public void setSigV4AuthProviderEnabled(boolean enabled)
This will enable the Amazon Signature V4 AuthProvider implementation for the connection using the
AWS region defined in the property setAwsRegion(String) (or setAwsRegion(Region)).
See
Authentication reference and
Amazon Signature V4 authenticator plugin for Java driver for further information.
enabled - Whether the Amazon Signature V4 auth provider is enabled.Copyright © 2020–2026 ING Bank. All rights reserved.