简体   繁体   English

RJDBC Cassandra-> .jfindClass(as.character(driverClass)[1])中的错误:找不到类

[英]RJDBC Cassandra -> Error in .jfindClass(as.character(driverClass)[1]) : class not found

I am trying to connect R to Cassandra and I am getting the following error - even though I explicitly add this directory folder to the classpath before I run the code (and I also point to the classpath within the statement)? 我正在尝试将R连接到Cassandra,并且遇到以下错误-即使在运行代码之前我已将该目录文件夹显式添加到类路径中(并且我也指向了语句中的类路径)? Thanks for any help! 谢谢你的帮助!

require(RJDBC) 要求(RJDBC)

.jaddClassPath("C:\\Users\\atrombley\\Desktop\\R\\")
cassdrv <- JDBC("org.apache.cassandra.cql.jdbc.CassandraDriver",
                "C:\\Users\\atrombley\\Desktop\\R\\cassandra-jdbc-1.2.5.jar")

Error in .jfindClass(as.character(driverClass)[1]) : class not found .jfindClass(as.character(driverClass)[1])中的错误:找不到类

In my case, the database driver was missing from the location named in my call of JDBC(). 就我而言,在我的JDBC()调用中命名的位置中缺少数据库驱动程序。 Just added the Jar to that location and it works! 只需将Jar添加到该位置即可使用! For example: 例如:

JDBC(driverClass="com.vertica.jdbc.Driver", classPath="C:/Program Files/Vertica Systems/JDBC/vertica-jdbc-7.2.1-0.jar")

This helpful clue resulted from turning on debugging: 这个有用的线索来自打开调试:

.jclassLoader()$setDebug(1L)

as advised here: https://github.com/su/RJDBC/issues/26 如此处建议的那样: https : //github.com/su/RJDBC/issues/26

Cassandra JDBC driver v1.2.5 does not work with Cassandra 2.* and is very very deprecated, still uses the thrift API and does only connect to a single node. Cassandra JDBC驱动程序v1.2.5不适用于Cassandra 2. *,并且非常不推荐使用,仍然使用节俭API,并且仅连接到单个节点。

You should grab the new version I made that uses the Datastax Java Driver underneath : https://github.com/adejanovski/java-driver 您应该在下面获取使用Datastax Java驱动程序制作的新版本: https : //github.com/adejanovski/java-driver

Here's a link to the compiled version with all the necessary dependencies : https://drive.google.com/file/d/0B7fwX0DqcWSTLUFqSEMxVFVWY2M/view?usp=sharing 这是具有所有必需依赖项的已编译版本的链接: https : //drive.google.com/file/d/0B7fwX0DqcWSTLUFqSEMxVFVWY2M/view?usp=sharing

Use the appropriate driver class and JDBC url as shown on this page : https://github.com/adejanovski/java-driver/tree/2.1/driver-jdbc 使用此页面上所示的适当的驱动程序类和JDBC URL: https : //github.com/adejanovski/java-driver/tree/2.1/driver-jdbc

Another more efficient option (though I'm not familiar with R) should be to use R on Spark and access Cassandra through the spark-cassandra connector provided by Datastax. 另一个更有效的选择(尽管我对R不熟悉)应该是在Spark上使用R并通过Datastax提供的spark-cassandra连接器访问Cassandra。

So, the documentation is terrible out there, I was able to find out that you need the following "Dependency" jars, AND you need to put them in the same folder as the driver jar file. 因此,该文档太糟糕了,我发现您需要以下“ Dependency”罐子,并且需要将它们与驱动程序jar文件放在同一文件夹中。

List of JARS: JARS列表:

apache-cassandra-thrift-1.2.6 cassandra-jdbc-2.1.1 log4j-1.2.15 slf4j-simple-1.5.2 libthrift-0.7.0 jackson-core-asl-1.9.2 cassandra-all-1.2.9 slf4j-api-1.5.2 apache-cassandra-clientutil-1.2.6 jackson-mapper-asl-1.9.2 guava-15.0 slf4j-log4j12-1.5.2 apache-cassandra-thrift-1.2.6 cassandra-jdbc-2.1.1 log4j-1.2.15 slf4j-simple-1.5.2 libthrift-0.7.0 jackson-core-asl-1.9.2 cassandra-all-1.2.9 slf4j -api-1.5.2 apache-cassandra-clientutil-1.2.6 jackson-mapper-asl-1.9.2番石榴15.0 slf4j-log4j12-1.5.2

However, even if you do get lucky enough to resolve this issue and R finds your driver, you will then have a problem and get the error below which no one seems to have fixed yet...... 但是,即使您确实很幸运能够解决此问题并且R找到了您的驱动程序,您也将遇到问题并得到错误,在该错误之下,似乎还没有人解决。

log4j:WARN No appenders could be found for logger (org.apache.cassandra.cql.jdbc.CassandraDriver). log4j:WARN找不到记录程序的附加程序(org.apache.cassandra.cql.jdbc.CassandraDriver)。 log4j:WARN Please initialize the log4j system properly. log4j:WARN请正确初始化log4j系统。 Error in .jcall(drv@jdrv, "Ljava/sql/Connection;", "connect", as.character(url)[1], : java.sql.SQLNonTransientConnectionException: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2097152000)! .jcall(drv @ jdrv,“ Ljava / sql / Connection;”,“ connect”,as.character(url)[1],中的错误:java.sql.SQLNonTransientConnectionException:org.apache.thrift.transport.TTransportException:读取负帧大小(-2097152000)!

Please add cassandra-jdbc-1.2.5-1.0.0.jar file in cassandra/lib folder. 请在cassandra / lib文件夹中添加cassandra-jdbc-1.2.5-1.0.0.jar文件。 That working for me. 那对我有用。

None of the R examples worked for me, and I have read that even the ones that do work for you, you will have to build in pagination which is a pain in the a$$. 没有一个R示例对我有用,并且我读到即使是那些对您有用的示例,您也必须建立分页功能,这对于a $$来说是很痛苦的。 Just do it in python with this script, and it does the pagination for you. 只需使用此脚本在python中完成,它就会为您进行分页。

import sys
sys.path.append('/Library/Python/2.7/site-packages/')
import cql
from cassandra.cluster import Cluster
cluster = Cluster(contact_points=['10.121.xxx.xx'], protocol_version=3);
session = cluster.connect();
result = session.execute("select client_id, request_time, request_id,client_ip, exception, method, query_parameters, request_body, resource,response_duration_in_ms, response_http_code, user_id from api.api_usage_log")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 RJDBC问题:.jfindClass(as.character(driverClass)[1])中的错误:找不到类 - RJDBC issues: Error in .jfindClass(as.character(driverClass)[1]) : class not found .jfindClass(as.character(driverClass)[1]) 中的错误:找不到类 - Error in .jfindClass(as.character(driverClass)[1]) : class not found Cassandra 异常:在类上找不到@Table 注释 - Cassandra Exception : @Table annotation not found on the class 使用火花流没有找到Cassandra类 - Cassandra class not found using spark streaming configuration.yml出现错误:* driverClass-DROPWIZARD中的无法识别的字段 - configuration.yml has an error: * Unrecognized field at: driverClass - DROPWIZARD JAVA-Cassandra错误-找不到所需操作的编解码器 - JAVA - Cassandra ERROR - Codec not found for requested operation 未关闭的字符类错误? - Unclosed Character Class Error? Spring data cassandra:在类 User 上找不到要绑定构造函数的属性构建器 - Spring data cassandra: No property builder found on class User to bind constructor to 错误:无法找到或加载主类,Cassandra - Error: Could not find or load main class, Cassandra org.postgresql.Driver的bean类[org.springframework.jdbc.datasource.DriverManagerDataSource]的无效属性&#39;driverClass&#39; - Invalid property 'driverClass' of bean class [org.springframework.jdbc.datasource.DriverManagerDataSource] for org.postgresql.Driver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM