Reputation: 970
I am new to cassandra database.I am using play2.2.1 and mySQl database, but trying to migrate to cassandra database. I am using cassandra-2.1.3. While I can easily connect to the mySQl db, which is given by the following lines in the application.conf file. db.default.driver=com.mysql.jdbc.Driver db.default.url="jdbc:mysql://127.0.0.1:3306/mydatabase"
However I am not getting any idea as to what should be the db.default.url for cassandra. I have given the db.default.driver=com.datastax.driver.core
Edit: I have integrated the phantom DSL in my play applicatio https://github.com/websudos/phantom , but the page does not seem to tell anything about connecting to the database.
Edit:
For all new comers, the right place to look at is Getting started with Phantom which explains how to connect to Cassandra in greater detail.
Upvotes: 3
Views: 3754
Reputation: 28511
Phantom pre-bundles connectors so you can connect to a database while doing 0 work. All you need is to extend a Connector implementation and tell it which keyspace to use alongside with the relevant IPs and ports.
To simply connect to localhost:
import com.websudos.phantom.connectors.SimpleCassandraConnector
trait MyConnector extends SimpleCassandraConnector {
implicit val keySpace = KeySpace("my_app")
}
Now all that's left is to mixin this trait into all your table singletons and you're done. Checkout the connectors module for more information on how you can use more advanced deployments or even service discovery based connectors.
Update
As of Phantom 1.9.0, the connectors framework underwent a complete re-write.
import com.outworkers.phantom.connectors.{ ContactPoint, ContactPoints }
object Defaults {
val keySpace = ContactPoint.local.keySpace("myapp")
// val Connector = ContactPoints(Seq("localhost", "10.4.2.2"), 9042)
}
trait Connector extends Defaults.keySpace.Connector {
implicit val keySpace: KeySpace = KeySpace("my_app")
}
Upvotes: 6
Reputation: 11638
The datastax java-driver does not currently support JDBC (although there is a pull request opened), but even if there was using JDBC over the driver may not be an ideal way to interface with cassandra.
You should still be able to integrate Cassandra into your play application without too much trouble. Here are a few references that may be helpful:
Upvotes: 2