I have read some tutorials on what Cassandra is and what it can do but my problem is how to interface with Cassandra in java? (A tutorial will be nice :-) )
If possible, can someone please show me whether I should use Thrift or Hector (which one is better and why)?
Thanks in advance.
PS Can I integrate Hibernate with Cassandra?
In order to connect to Cassandra from Java, we need to build a Cluster object. An address of a node needs to be provided as a contact point. If we don't provide a port number, the default port (9042) will be used. These settings allow the driver to discover the current topology of a cluster.
You can execute CQL queries using execute() method of Session class. Pass the query either in string format or as a Statement class object to the execute() method. Whatever you pass to this method in string format will be executed on the cqlsh.
Cassandra is a distributed database management system which is open source with wide column store, NoSQL database to handle large amount of data across many commodity servers which provides high availability with no single point of failure. It is written in Java and developed by Apache Software Foundation.
Hibernate uses JDBC Drivers to connect to relational databases. Cassandra is a ColumnFamily based, which is A relational database (distributed one).
The problem is to find a proper JDBC driver for your case. Here is a project I Googled:
http://code.google.com/p/sql4d/
It's not active currently, but you got the idea of how to find the right one.
Having object-relationship mapping through Hibernate you won't have to worry about the specific dialect Cassandra use and just enjoy the ride.
Well.. that's how it sounds theoretically.
Yet another way is using Pelops library for usage of Cassandra. More info on it HERE.
Getting started with Cassandra - a rather short post on the matter.
Hope you find of your answers there!
New for 0.8 is CQL (Cassandra Query Language), an SQL-alike alternative to the traditional RPC interface. Language drivers are available for:
Java (JDBC) Python (DBAPI2) Twisted
http://cassandra.apache.org/download/
http://www.datastax.com/docs/0.8/api/cql_ref
Hibernate OGM looks like it might eventually be the answer.
Some example projects using Hector: https://github.com/zznate/cassandra-tutorial https://github.com/zznate/cassandra-stress
Another example (within the actual project) but using using the CQL JDBC driver with our (shiny new) JDBC-pool: https://github.com/riptano/jdbc-conn-pool/tree/master/portfolio-example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With