Skip to content

Commit eda9b1f

Browse files
kevin-atxmolivasdatfilipelautert
authored
Swapped in the new ING JDBC wrapper and the DataStax OSS Driver (#205)
* Swapped in the new ING JDBC wrapper and the DataStax OSS Driver * Compile changes * Updated to latest version of the JDBC wrapper Updated to the latest version of the JDBC wrapper since it was updated to work better with Liquibase. * Updating library to 4.9.1 * Merge fix * Add test file back --------- Co-authored-by: Mike Olivas <[email protected]> Co-authored-by: filipe <[email protected]>
1 parent 5eb87cc commit eda9b1f

File tree

4 files changed

+68
-19
lines changed

4 files changed

+68
-19
lines changed
Binary file not shown.

pom.xml

+10-4
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,17 @@
9999
<scope>test</scope>
100100
</dependency>
101101
<dependency>
102-
<groupId>com.datastax.jdbc</groupId>
103-
<artifactId>CassandraJDBC42</artifactId>
104-
<version>4.2</version>
102+
<groupId>com.ing.data</groupId>
103+
<artifactId>cassandra-jdbc-wrapper</artifactId>
104+
<version>4.9.1</version>
105105
<scope>system</scope>
106-
<systemPath>${basedir}/lib/CassandraJDBC42.jar</systemPath>
106+
<systemPath>${basedir}/lib/cassandra-jdbc-wrapper-4.9.1-bundle.jar</systemPath>
107+
</dependency>
108+
<dependency>
109+
<groupId>com.datastax.oss</groupId>
110+
<artifactId>java-driver-parent</artifactId>
111+
<version>4.17.0</version>
112+
<type>pom</type>
107113
</dependency>
108114
<dependency>
109115
<groupId>com.h2database</groupId>

src/main/java/liquibase/ext/cassandra/database/CassandraDatabase.java

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package liquibase.ext.cassandra.database;
22

3-
import com.simba.cassandra.cassandra.core.CDBJDBCConnection;
4-
import com.simba.cassandra.jdbc.jdbc42.S42Connection;
3+
import com.ing.data.cassandra.jdbc.CassandraConnection;
54
import liquibase.Scope;
65
import liquibase.database.AbstractJdbcDatabase;
76
import liquibase.database.DatabaseConnection;
@@ -13,14 +12,16 @@
1312

1413
/**
1514
* Cassandra 1.2.0 NoSQL database support.
15+
* Javadocs for ING Cassandra JDBC Wrapper: https://javadoc.io/doc/com.ing.data/cassandra-jdbc-wrapper/latest/index.html
16+
*
17+
* Javadocs for DataStax OSS Driver: https://javadoc.io/doc/com.datastax.oss/java-driver-core/latest/index.html
18+
* Jar file for DataStax OSS Driver: https://search.maven.org/search?q=com.DataStax.oss
1619
*/
1720
public class CassandraDatabase extends AbstractJdbcDatabase {
1821
public static final String PRODUCT_NAME = "Cassandra";
1922
public static final String SHORT_PRODUCT_NAME = "cassandra";
2023
public static final Integer DEFAULT_PORT = 9160;
21-
public static final String DEFAULT_DRIVER = "com.simba.cassandra.jdbc42.Driver";
22-
public static final String NO_JDBC_VERSION_DRIVER = "com.simba.cassandra.jdbc.Driver";
23-
24+
public static final String DEFAULT_DRIVER = "com.ing.data.cassandra.jdbc.CassandraDriver";
2425
private String keyspace;
2526

2627
@Override
@@ -67,12 +68,7 @@ public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws D
6768
@Override
6869
public String getDefaultDriver(String url) {
6970
if (String.valueOf(url).startsWith("jdbc:cassandra:")) {
70-
try {
71-
Class.forName(DEFAULT_DRIVER);
72-
return DEFAULT_DRIVER;
73-
} catch (ClassNotFoundException e) {
74-
return NO_JDBC_VERSION_DRIVER;
75-
}
71+
return DEFAULT_DRIVER;
7672
}
7773
return null;
7874
}
@@ -115,10 +111,7 @@ public String getCurrentDateTimeFunction() {
115111
public String getKeyspace() {
116112
if (keyspace == null) {
117113
try {
118-
if (this.getConnection() instanceof JdbcConnection) {
119-
keyspace = ((CDBJDBCConnection) ((S42Connection) ((JdbcConnection) (this).getConnection())
120-
.getUnderlyingConnection()).getConnection()).getSession().getLoggedKeyspace();
121-
}
114+
keyspace = ((CassandraConnection) (this).getConnection()).getSession().getKeyspace().toString();
122115
} catch (Exception e) {
123116
Scope.getCurrentScope().getLog(CassandraDatabase.class)
124117
.severe("Could not get keyspace from connection", e);

test.cql

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
CREATE KEYSPACE betterbotz
2+
WITH REPLICATION = {
3+
'class' : 'SimpleStrategy',
4+
'replication_factor' : 1
5+
};
6+
USE betterbotz;
7+
DROP TABLE IF EXISTS authors;
8+
CREATE TABLE authors (
9+
id int,
10+
first_name varchar,
11+
last_name varchar,
12+
email varchar,
13+
birthdate date,
14+
added timestamp,
15+
PRIMARY KEY (id)
16+
);
17+
18+
INSERT INTO authors(id, first_name, last_name, email, birthdate, added) VALUES
19+
(1,'Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25');
20+
INSERT INTO authors(id, first_name, last_name, email, birthdate, added) VALUES
21+
(2,'Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00');
22+
INSERT INTO authors(id, first_name, last_name, email, birthdate, added) VALUES
23+
(3,'Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48');
24+
INSERT INTO authors(id, first_name, last_name, email, birthdate, added) VALUES
25+
(4,'Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41');
26+
INSERT INTO authors(id, first_name, last_name, email, birthdate, added) VALUES
27+
(5,'Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00');
28+
29+
30+
DROP TABLE IF EXISTS posts;
31+
CREATE TABLE posts (
32+
id int,
33+
author_id int,
34+
title varchar,
35+
description varchar,
36+
content text,
37+
inserted_date date,
38+
PRIMARY KEY (id)
39+
);
40+
41+
INSERT INTO posts(id, author_id, title, description, content, inserted_date) VALUES
42+
(1,1,'temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18');
43+
INSERT INTO posts(id, author_id, title, description, content, inserted_date) VALUES
44+
(2,2,'ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08');
45+
INSERT INTO posts(id, author_id, title, description, content, inserted_date) VALUES
46+
(3,3,'illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25');
47+
INSERT INTO posts(id, author_id, title, description, content, inserted_date) VALUES
48+
(4,4,'itaque','deleniti','Magni nam optio id recusandae.','2010-07-28');
49+
INSERT INTO posts(id, author_id, title, description, content, inserted_date) VALUES
50+
(5,5,'ad','similique','Rerum tempore quis ut nesciunt qui excepturi est.','2006-10-09');

0 commit comments

Comments
 (0)