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



saffy avatar image
saffy asked smadhavan commented

Getting IO exception connecting to Astra DB

I am getting below error while trying to connect astra through java driver . code is same as given in java doc

Path given for secure-connect bundle is correct and I have passed client id and client secret.

Please find the code

public class ConnectDatabase {

   public static void main(String[] args) {
       // Create the CqlSession object:
       try (CqlSession session = CqlSession.builder()
           .withAuthCredentials("<<CLIENT ID>>","<<CLIENT SECRET>>")
           .build()) {
           // Select the release_version from the system.local table:
           ResultSet rs = session.execute("select release_version from system.local");
           Row row =;
           //Print the results of the CQL query to the console:
           if (row != null) {
           } else {
               System.out.println("An error occurred.");

Getting below error

Exception in thread "main" com.datastax.oss.driver.api.core.DriverExecutionException
    at com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures.getUninterruptibly(
    at com.booksrepo.betterreads.test.main(
Caused by: Server returned HTTP response code: 400 for URL:
    at java.base/
    at java.base/
    at java.base/
    at com.datastax.oss.driver.api.core.session.SessionBuilder.buildDefaultSessionAsync(
    at com.datastax.oss.driver.api.core.session.SessionBuilder.buildAsync(
... 2 more
java driverastra db
1 comment
10 |1000

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

@saffy I am unable to reproduce this either. Could you please update your question with details about the Java Driver version (a maven POM dependency section would be good here) along with the complete stacktrace here? If you want, you could check-in your codebase (of course, without any username/passwords) into a GitHub repo and share us that link to help speed up the triage.
0 Likes 0 ·

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

Unfortunately, I'm unable to replicate the issue you reported.

Please try these 2 things:

  1. Check that the database you're connecting to is active and operational. The quickest way to test this is by running the SELECT statement in your code on the CQL Console of your Astra DB.
  2. Add a call to the withKeyspace() method in the session builder of your code, specifying your keyspace.


10 |1000

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