1
votes

The answer i'm seeking is the dependencies which i'll be needing to connect to cassandra through play-scala. cassandra version 2.2.0, play version-2.4

my build.sbt file:

name := """basic-form"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.6"
libraryDependencies ++= Seq(   
"com.typesafe.akka"      %% "akka-actor"            % "2.2.0",   "com.typesafe.akka"      %% "akka-slf4j"            % "2.2.0","com.datastax.cassandra"  % "cassandra-driver-core" % "2.0.2")

On importing "com.datastax.driver.core.Cluster" error comes that datastax is not member of com

suggestions would be appreciated.

2
Hi. Provide more details on your question, like more information, code and what have you tried, that makes it easier for others to help you. - William Janoti
Wouldn't it also be necessary to set the db.default.driver and db.default.url of play as well, in addition to adding the dependencies? - Mnemosyne

2 Answers

2
votes

The official DataStax Java Driver for Cassandra is available at https://datastax.github.io/java-driver/. You won't need anything more than importing the dependency in your SBT build, and reading the documentation to get started.

7
votes

You can use DataStax driver as @manub wrote.

If you are pretty novice, then, literally, you need o add this string to your build.sbt file

libraryDependencies += "com.datastax.cassandra" % "cassandra-driver-core" % "3.0.0"

And the connection example

object CassandraClient {
 private val cluster = Cluster.builder()
  .addContactPoint("localhost")
  .withPort(9042)
  .build()

  val session = cluster.connect()

  def getValueFromCassandraTable() = {
    session.execute("SELECT * FROM mykeyspace.users")
  }
}