Skip to content

Commit f9be072

Browse files
committed
Rework the driver to behave as a very basic wrapper of Couchbase Java client
* The only one column ("result") in a result set, containing resulting JSON converted to Java's Map<String, Object> * No Database meta information for now except database version
1 parent 5958d4a commit f9be072

39 files changed

+424
-1890
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'java'
33
}
44

5-
version '1.3.5'
5+
version '0.1.0'
66

77
sourceCompatibility = 1.8
88

@@ -27,7 +27,7 @@ sourceSets {
2727
}
2828

2929
dependencies {
30-
compile group: 'com.datastax.cassandra', name: 'cassandra-driver-core', version: '3.6.0'
30+
compile 'com.couchbase.client:java-client:3.0.5'
3131
testCompile group: 'junit', name: 'junit', version: '4.12'
3232
}
3333

driver/src/main/java/com/dbschema/CassandraJdbcDriver.java

Lines changed: 0 additions & 147 deletions
This file was deleted.

driver/src/main/java/com/dbschema/CassandraBaseStatement.java renamed to driver/src/main/java/com/dbschema/CouchbaseBaseStatement.java

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
package com.dbschema;
22

3-
import com.datastax.driver.core.BatchStatement;
4-
import com.datastax.driver.core.Session;
5-
import com.datastax.driver.core.exceptions.SyntaxError;
3+
import com.couchbase.client.java.Cluster;
4+
import com.couchbase.client.java.query.QueryResult;
65

7-
import java.sql.*;
6+
import java.sql.Connection;
7+
import java.sql.ResultSet;
8+
import java.sql.SQLException;
9+
import java.sql.SQLFeatureNotSupportedException;
10+
import java.sql.SQLWarning;
11+
import java.sql.Statement;
812

913
/**
1014
* @author Liudmila Kornilova
1115
**/
12-
public abstract class CassandraBaseStatement implements Statement {
13-
final com.datastax.driver.core.Session session;
14-
BatchStatement batchStatement = null;
16+
public abstract class CouchbaseBaseStatement implements Statement {
17+
final Cluster cluster;
1518
private boolean isClosed = false;
16-
CassandraResultSet result;
19+
CouchbaseResultSet result;
1720

18-
CassandraBaseStatement(Session session) {
19-
this.session = session;
21+
CouchbaseBaseStatement(Cluster cluster) {
22+
this.cluster = cluster;
2023
}
2124

2225
@Override
@@ -35,16 +38,10 @@ public boolean isClosed() {
3538
return isClosed;
3639
}
3740

38-
boolean executeInner(com.datastax.driver.core.ResultSet resultSet, boolean returnNullStrings) throws SQLException {
41+
boolean executeInner(QueryResult resultSet, boolean returnNullStrings) throws SQLException {
3942
try {
40-
result = new CassandraResultSet(this, resultSet, returnNullStrings);
41-
if (!result.isQuery()) {
42-
result = null;
43-
return false;
44-
}
43+
result = new CouchbaseResultSet(this, resultSet, returnNullStrings);
4544
return true;
46-
} catch (SyntaxError ex) {
47-
throw new SQLSyntaxErrorException(ex.getMessage(), ex);
4845
} catch (Throwable t) {
4946
throw new SQLException(t.getMessage(), t);
5047
}
@@ -64,20 +61,7 @@ public int getUpdateCount() throws SQLException {
6461

6562
@Override
6663
public int[] executeBatch() throws SQLException {
67-
if (batchStatement == null) throw new SQLException("No batch statements were submitted");
68-
int statementsCount = batchStatement.size();
69-
try {
70-
session.execute(batchStatement);
71-
} catch (Throwable t) {
72-
throw new SQLException(t.getMessage(), t);
73-
} finally {
74-
batchStatement = null;
75-
}
76-
int[] res = new int[statementsCount];
77-
for (int i = 0; i < statementsCount; i++) {
78-
res[i] = SUCCESS_NO_INFO;
79-
}
80-
return res;
64+
throw new SQLFeatureNotSupportedException();
8165
}
8266

8367
@Override
@@ -152,7 +136,7 @@ public void setQueryTimeout(int seconds) throws SQLException {
152136

153137
@Override
154138
public void cancel() throws SQLException {
155-
throw new SQLFeatureNotSupportedException("Cassandra provides no support for interrupting an operation.");
139+
throw new SQLFeatureNotSupportedException("Couchbase provides no support for interrupting an operation.");
156140
}
157141

158142
@Override

0 commit comments

Comments
 (0)