R和cassandra连接错误 [英] R and cassandra connection error

查看:727
本文介绍了R和cassandra连接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

library(RJDBC)




cassdrv <- JDBC("org.apache.cassandra.cql.jdbc.CassandraDriver",
                    list.files("/home/beyhan/Downloads/jars/",pattern="jar$",full.names=T))

    casscon <- dbConnect(cassdrv, "jdbc:cassandra://localhost:9042")

p>

Output

> cassdrv <- JDBC("org.apache.cassandra.cql.jdbc.CassandraDriver",
+ list.files("/home/beyhan/Downloads/jars/",pattern="jar$",full.names=T))
> casscon <- dbConnect(cassdrv, "jdbc:cassandra://localhost:9042")




错误.jcall(drv @ jdrv,Ljava / sql / Connection;,connect,
as.character(url)[:] java.lang.NoClassDefFoundError:
org / apache / thrift / transport / TTransportException

Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], : java.lang.NoClassDefFoundError: org/apache/thrift/transport/TTransportException


推荐答案

允许您在R中访问Cassandra数据。要清楚,我们的驱动程序创建了一个关于Cassandra数据的关系接口,允许您通过我们的驱动程序向Cassandra提交SQL查询(内部,我们将SQL转换为CQL,发送请求,将结果作为关系数据库返回。)

Our JDBC Driver for Cassandra allows you to access your Cassandra data in R. To be clear, our driver creates a relational interface to your Cassandra data, allowing you to submit SQL queries to Cassandra through our driver (internally, we translate the SQL to CQL, send the request and return the results as a relational database).

我们有一个文章在我们的知识库中连接,但我也在这里转录它。

We have an article in our Knowledge Base for connecting, but I'll transcribe it here as well.


  1. 载入RJDBC套件:

  1. Load the RJDBC Package:

library(RJDBC)


  • 设置驱动程序类和类路径:

  • Set the driver class and classpath:

    driver <- JDBC(driverClass = "cdata.jdbc.cassandra.CassandraDriver", classPath = "MyInstallationDir\lib\cdata.jdbc.cassandra.jar", identifier.quote = "'")
    


  • 初始化JDBC连接:

  • Initialize the JDBC connection:

    conn <- dbConnect(driver,"Database=MyCassandraDB;Port=7000;Server=127.0.0.1;")
    

    (设置要连接到Cassandra的服务器,端口和数据库连接属性。)

    (Set the Server, Port, and Database connection properties to connect to Cassandra.)


    b $ b

    此时,您可以在R中执行标准操作,例如:

    At this point, you can perform standards actions available in R, like:


    • Listing the tables:

    dbListTables(conn)
    


  • 执行Cassandra API支持的任何SQL查询:

  • Executing any SQL query supported by the Cassandra API:

    customer <- dbGetQuery(conn,"SELECT City, SUM(TotalDue) FROM Customer GROUP BY City")
    


  • 结果:

  • Viewing the results:

    View(customer)
    

    / li>

  • 随时可以下载免费Beta 的驱动程序!如果您有任何问题,请告诉我们。

    Feel free to download a free Beta of the driver! If you have any questions, please let us know.

    这篇关于R和cassandra连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆