From 0c783aaf7af0de01c7baf465b0a17f28deb3671c Mon Sep 17 00:00:00 2001 From: Damien CAROL Date: Thu, 19 Dec 2013 10:18:41 +0100 Subject: [PATCH] Implementing batch query with naive implementation. --- .../phoenix/jdbc/PhoenixStatement.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatement.java b/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatement.java index 0fcc96d5..9a07436e 100644 --- a/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatement.java +++ b/src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatement.java @@ -161,7 +161,7 @@ public String toString() { private boolean isClosed = false; private ResultSetMetaData resultSetMetaData; private int maxRows; - + private List batchQueryList = new ArrayList(); public PhoenixStatement(PhoenixConnection connection) { this.connection = connection; @@ -947,7 +947,9 @@ public Format getFormatter(PDataType type) { @Override public void addBatch(String sql) throws SQLException { - throw new SQLFeatureNotSupportedException(); + // Naive implementation + // Simple add queries to a new list of String + this.batchQueryList.add(sql); } @Override @@ -957,7 +959,7 @@ public void cancel() throws SQLException { @Override public void clearBatch() throws SQLException { - throw new SQLFeatureNotSupportedException(); + this.batchQueryList.clear(); } @Override @@ -1053,7 +1055,17 @@ public boolean execute(String sql, String[] columnNames) throws SQLException { @Override public int[] executeBatch() throws SQLException { - throw new SQLFeatureNotSupportedException(); + + int[] rets = new int[this.batchQueryList.size()]; + int i=0; + + for (String sql : this.batchQueryList) + { + execute(sql); + rets[i++] = Statement.SUCCESS_NO_INFO; + } + + return rets; } @Override