在 Java 中连接和使用 Cassandra
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3246516/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Connecting and playing with Cassandra in Java
提问by Buhake Sindi
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 :-) )
我已经阅读了一些关于 Cassandra 是什么以及它可以做什么的教程,但我的问题是如何在 Java 中与 Cassandra 交互?(教程会很好:-))
If possible, can someone please show me whether I should use Thrift or Hector (which one is better and why)?
如果可能的话,有人可以告诉我我应该使用 Thrift 还是 Hector(哪个更好,为什么)?
Thanks in advance.
提前致谢。
PSCan I integrate Hibernate with Cassandra?
PS我可以将 Hibernate 与 Cassandra 集成吗?
回答by vlood
Hibernate uses JDBC Drivers to connect to relational databases. Cassandra is a ColumnFamily based, which is A relational database (distributed one).
Hibernate 使用 JDBC 驱动程序连接到关系数据库。Cassandra 是一个基于 ColumnFamily 的,它是一个关系型数据库(分布式的)。
The problem is to find a proper JDBC driver for your case. Here is a project I Googled:
问题是为您的情况找到合适的 JDBC 驱动程序。这是我用谷歌搜索的一个项目:
http://code.google.com/p/sql4d/
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.
通过 Hibernate 进行对象关系映射,您不必担心 Cassandra 使用的特定方言,只需享受旅程。
Well.. that's how it sounds theoretically.
嗯..这就是理论上的声音。
Yet another way is using Pelops library for usage of Cassandra. More info on it HERE.
另一种方法是使用 Pelops 库来使用 Cassandra。关于它的更多信息在这里。
Getting started with Cassandra- a rather short post on the matter.
Cassandra 入门- 关于这个问题的一篇相当短的文章。
Hope you find of your answers there!
希望你能在那里找到答案!
回答by JustusTh
New for 0.8 is CQL (Cassandra Query Language), an SQL-alike alternative to the traditional RPC interface. Language drivers are available for:
0.8 的新功能是 CQL(Cassandra 查询语言),它是传统 RPC 接口的类似 SQL 的替代方案。语言驱动程序可用于:
Java (JDBC) Python (DBAPI2) Twisted
Java (JDBC) Python (DBAPI2) 扭曲
http://cassandra.apache.org/download/
http://cassandra.apache.org/download/
回答by user738048
Hibernate OGM looks like it might eventually be the answer.
Hibernate OGM 看起来最终可能是答案。
回答by zznate
Some example projects using Hector: https://github.com/zznate/cassandra-tutorialhttps://github.com/zznate/cassandra-stress
一些使用 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
另一个示例(在实际项目中)但使用 CQL JDBC 驱动程序和我们的(闪亮的新)JDBC 池:https: //github.com/riptano/jdbc-conn-pool/tree/master/portfolio-example

