cassandracqlcassandra-3.0cassandra-2.0

What dependencies should I use for Cassandra Java driver 4.13?


so I'm having some trouble when I connect to Cassandra(Version:3.11.10).

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.AbstractMethodError:

Could someone tell me what dependencies should I use for it if I'm using java-driver-core 4.13.0. My currently dependencies are:

Java-driver-core version 4.13.0 Java-driver-query-builder version 4.13.0 Java-driver-mapper-runtime version 4.13.0 Guava version 14.0.1 log4j-over-slf4j versiona 1.7.13 metrics-core version 3.0.2 netty-all 4.0.28.Final slf4j-api version 1.7.13 slf4j-nop version 1.7.21

And also could you share your example of your class connection. Thanks.


Solution

  • Here's a sample pom.xml from the Java driver manual:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
    
      <groupId>com.example.yourcompany</groupId>
      <artifactId>yourapp</artifactId>
      <version>1.0.0-SNAPSHOT</version>
    
      <dependencies>
        <dependency>
          <groupId>com.datastax.oss</groupId>
          <artifactId>java-driver-core</artifactId>
          <version>${driver.version}</version>
        </dependency>
        <dependency>
          <groupId>ch.qos.logback</groupId>
          <artifactId>logback-classic</artifactId>
          <version>1.2.3</version>
        </dependency>
      </dependencies>
    
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </project>
    

    In case you weren't aware, we have a free hands-on tutorial here that will show you how to do CRUD operations with the Java driver. There are lots of other free interactive tutorials at datastax.com/dev that I think you'll find useful.

    As a side note, as a developer you might be interested in Stargate.io -- a data platform that lets you connect to Cassandra using REST, GraphQL and JSON/Doc APIs. For example, creating a new record is as easy as sending a POST request to /api/rest/v2/keyspaces/db_name/table_name/. You can easily do CRUD operations with API calls in your app. It is open-source so it's free to use.

    You can try it free (no credit card required) -- Astra DB comes with Stargate bundled in so it's pre-configured and ready to use. Launch a free Cassandra cluster in just a few clicks here to play with Stargate. Cheers!