How can I connect Cassandra DB using its JDBC driver in Matlab?

7 ビュー (過去 30 日間)
Jasim Waheed Ansari
Jasim Waheed Ansari 2017 年 12 月 13 日
Hello, I am pretty new to Matlab. I have a task to connect the Cassandra cluster using Matlab. I do have an access to Cassandra JDBC driver jar, therefore I wrote a test script to test if I could connect to cluster. Where am I going wrong. Thanks.
function cassandra_matlab
cassandra_jdbc_path='C:/Users/adm_lokal/Downloads/cassandra-jdbc-wrapper-3.1.0-SNAPSHOT.jar';
javaaddpath(cassandra_jdbc_path)
datasource='cassandra';
username='';
password='';
driver='org.apache.cassandra2.cql.jdbc.CassandraDriver';
url='jdbc:cassandra://127.0.0.1:9042/project_fvag_dev';
%connecting to cassandra cluster
conn=database(datasource,username,password,driver,url);
print('connected!!!');
selectquery='SELECT * from project_fvag_dev.zeit2_schnellemessrate_6dof_033 LIMIT 5';
data=select(conn,selectquery);
close(conn);
Output: Error using database (line 158) Java exception occurred: com.google.common.util.concurrent.ExecutionError: java.lang.ExceptionInInitializerError
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
at com.google.common.cache.LocalCache.get(LocalCache.java:3932)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3936)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4806)
at com.github.adejanovski.cassandra.jdbc.CassandraDriver.connect(CassandraDriver.java:102)
at com.mathworks.toolbox.database.DrivJDBC.connect(DatabaseConnection.java:30)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.mathworks.toolbox.database.DatabaseConnection.<init>(DatabaseConnection.java:151)
Caused by: java.lang.ExceptionInInitializerError
at com.github.adejanovski.cassandra.jdbc.SessionHolder.createSession(SessionHolder.java:137)
at com.github.adejanovski.cassandra.jdbc.SessionHolder.<init>(SessionHolder.java:83)
at com.github.adejanovski.cassandra.jdbc.CassandraDriver$1.load(CassandraDriver.java:68)
at com.github.adejanovski.cassandra.jdbc.CassandraDriver$1.load(CassandraDriver.java:65)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3522)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2315)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2278)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2193)
... 8 more
Caused by: java.lang.IllegalStateException: Detected Guava issue #1635 which indicates that a version of Guava less than 16.01 is in use. This introduces codec resolution issues and potentially other incompatibility issues in the driver. Please upgrade to Guava 16.01 or later.
at com.datastax.driver.core.SanityChecks.checkGuava(SanityChecks.java:62)
at com.datastax.driver.core.SanityChecks.check(SanityChecks.java:36)
at com.datastax.driver.core.Cluster.<clinit>(Cluster.java:67)
... 16 more
Error in cassandra_matlab (line 11) conn=database(datasource,username,password,driver,url);

回答 (1 件)

MathWorks Computational Finance Team
MathWorks Computational Finance Team 2018 年 11 月 9 日
As of MATLAB R2018b, you can connect to Cassandra without the JDBC driver using the Database Toolbox™ Interface for Apache Cassandra® Database. You can find more information on this here:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by