Registering the Connector Class

Before connecting to your data, you must register the appropriate class for your application.

The following classes are used to connect the Simba Cassandra JDBC Connector to Cassandra data stores:

  • The Driver classes extend java.sql.Driver.
  • The DataSource classes extend javax.sql.DataSource and javax.sql.ConnectionPoolDataSource.

The connector supports the following fully-qualified class names (FQCNs) that are independent of the JDBC version:

  • com.simba..jdbc.Driver
  • com.simba..jdbc.DataSource

To support JDBC 4.0, classes with the following fully-qualified class names (FQCNs) are available:

  • com.simba.cassandra.jdbc4.Driver
  • com.simba.cassandra.jdbc4.DataSource
Note:

Support for JDBC 4.0 and 4.1 are deprecated, and will be removed in a future release of this connector. For more information, see the release notes.

To support JDBC 4.1, classes with the following FQCNs are available:

  • com.simba.cassandra.jdbc41.Driver
  • com.simba.cassandra.jdbc41.DataSource

To support JDBC 4.2, classes with the following FQCNs are available:

  • com.simba.cassandra.jdbc42.Driver
  • com.simba.cassandra.jdbc42.DataSource

The following sample code shows how to use the DriverManager class to establish a connection for JDBC 4.2:

private static Connection connectViaDM() throws Exception

{

Connection connection = null;

connection = DriverManager.getConnection(CONNECTION_URL);

return connection;

}

The following sample code shows how to use the DataSource class to establish a connection:

private static Connection connectViaDS() throws Exception

{

Connection connection = null;

DataSource ds = new com.simba.cassandra.jdbc42.DataSource();

com.simbacassandra..jdbc.DataSource();

ds.setURL(CONNECTION_URL);

connection = ds.getConnection();

return connection;

}