Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

njamkhande_188524 avatar image
njamkhande_188524 asked ·

Simba JDBC driver fails to create simple datasource

We are assessing DataStax Astra and want to use a JDBC driver for our tests that is capable of connecting to Astra as well as local test cassandra DB. The Simba JDBC driver listed at https://downloads.datastax.com/#odbc-jdbc-drivers seem like a good candidate. However following the documentation (https://docs.datastax.com/en/driver-matrix/doc/latestSimbaCassJDBCDriver.html), the simplest method of creating a DataSource doesn't work. This sample code from the doc -

Connection connection = null; 
DataSource ds = new com.simba.cassandra.jdbc42.DataSource(); 
ds.setURL("jdbc:cassandra://localhost:57668;DefaultKeyspace=runtime;AuthMech=1"); 
connection = ds.getConnection(); 

Fails with -

Exception in thread "main" java.sql.SQLException: Error creating Driver, Driver class name incorrect.
at com.simba.cassandra.jdbc.common.AbstractDataSource.doInitialize(Unknown Source)
at com.simba.cassandra.jdbc.common.AbstractDataSource.getSimbaConnection(Unknown Source)
at com.simba.cassandra.jdbc.common.AbstractDataSource.getConnection(Unknown Source)
at com.sample.App1.main(App1.java:14)
Caused by: com.simba.cassandra.support.exceptions.GeneralException: Error creating Driver, Driver class name incorrect.
at com.simba.cassandra.dsi.core.impl.DSIDriverFactory.createDriver(Unknown Source)
... 4 more
Caused by: java.lang

Is there anything in particular I am missing? Just to note, we use a library that needs a DataSource to be passed in as an argument. The other option of connecting using a DriverManager is not an option for us.

astrajdbc driver
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

You need to specify the secure connect bundle to your database in the connection URL.

It should look something like this:

jdbc:cassandra://;AuthMech=2;UID=<YOUR USER ID>;PWD=<YOUR PASSWORD>;SecureConnectionBundlePath=<PATH TO YOUR SECURE CONNECT BUNDLE>;

Have a look at this blog post from Sebastian Estevez for details. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.