|
@@ -1,9 +1,9 @@
|
|
|
package com.wecise.odb.jdbc;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
-import com.wecise.odb.Connector;
|
|
|
import com.wecise.odb.Error;
|
|
|
import com.wecise.odb.Message;
|
|
|
+import redis.clients.jedis.Jedis;
|
|
|
|
|
|
import java.sql.*;
|
|
|
import java.util.ArrayList;
|
|
@@ -619,7 +619,7 @@ public class ODBDatabaseMetaData implements DatabaseMetaData {
|
|
|
|
|
|
@Override
|
|
|
public ResultSet getTables(String catalog, String schem, String tableNamePattern, String[] type) throws SQLException {
|
|
|
- Connector ctr = ((ODBConnection)this.connection).getConnector();
|
|
|
+ Jedis ctr = ((ODBConnection)this.connection).getConnector();
|
|
|
try {
|
|
|
HashMap<String, Object> body = new HashMap<>();
|
|
|
body.put("keyspace", ((ODBConnection)this.connection).getKeyspace());
|
|
@@ -628,12 +628,11 @@ public class ODBDatabaseMetaData implements DatabaseMetaData {
|
|
|
body.put("tablename", tableNamePattern);
|
|
|
body.put("type", type);
|
|
|
|
|
|
- Message recvmsg = ctr.request("/odb/system/tables", new Gson().toJson(body));
|
|
|
- if (recvmsg == null) {
|
|
|
- throw new SQLException(Error.unableConnectServer);
|
|
|
- }
|
|
|
+ Object o = ctr.sendCommand(ODBCommandProtocol.JDBC.jdbc, "tables", new Gson().toJson(body));
|
|
|
+ String recvmsg = new String((byte[]) o);
|
|
|
+
|
|
|
Gson gs = new Gson();
|
|
|
- Map recvBody = gs.fromJson(recvmsg.getBody(), Map.class); // {message:{data:[...],meta:{...}}, status:""}
|
|
|
+ Map recvBody = gs.fromJson(recvmsg, Map.class); // {message:{data:[...],meta:{...}}, status:""}
|
|
|
String status = recvBody.get("status").toString();
|
|
|
if (status.equals("success")) {
|
|
|
Map msg = (Map) recvBody.get("message");
|
|
@@ -735,7 +734,7 @@ public class ODBDatabaseMetaData implements DatabaseMetaData {
|
|
|
|
|
|
@Override
|
|
|
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
|
|
|
- Connector ctr = ((ODBConnection)this.connection).getConnector();
|
|
|
+ Jedis ctr = ((ODBConnection)this.connection).getConnector();
|
|
|
try {
|
|
|
HashMap<String, Object> body = new HashMap<>();
|
|
|
body.put("keyspace", ((ODBConnection)this.connection).getKeyspace());
|
|
@@ -744,12 +743,11 @@ public class ODBDatabaseMetaData implements DatabaseMetaData {
|
|
|
body.put("tablename", tableNamePattern);
|
|
|
body.put("column", columnNamePattern);
|
|
|
|
|
|
- Message recvmsg = ctr.request("/odb/system/columns", new Gson().toJson(body));
|
|
|
- if (recvmsg == null) {
|
|
|
- throw new SQLException(Error.unableConnectServer);
|
|
|
- }
|
|
|
+ Object o = ctr.sendCommand(ODBCommandProtocol.JDBC.jdbc, "columns", new Gson().toJson(body));
|
|
|
+ String recvmsg = new String((byte[]) o);
|
|
|
+
|
|
|
Gson gs = new Gson();
|
|
|
- Map recvBody = gs.fromJson(recvmsg.getBody(), Map.class); // {message:{data:[...],meta:{...}}, status:""}
|
|
|
+ Map recvBody = gs.fromJson(recvmsg, Map.class); // {message:{data:[...],meta:{...}}, status:""}
|
|
|
String status = recvBody.get("status").toString();
|
|
|
if (status.equals("success")) {
|
|
|
Map msg = (Map) recvBody.get("message");
|