Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Start implementing batch query #602 #636

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/main/java/com/salesforce/phoenix/jdbc/PhoenixStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public String toString() {
private boolean isClosed = false;
private ResultSetMetaData resultSetMetaData;
private int maxRows;

private List<String> batchQueryList = new ArrayList<String>();

public PhoenixStatement(PhoenixConnection connection) {
this.connection = connection;
Expand Down Expand Up @@ -875,7 +875,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
Expand All @@ -885,7 +887,7 @@ public void cancel() throws SQLException {

@Override
public void clearBatch() throws SQLException {
throw new SQLFeatureNotSupportedException();
this.batchQueryList.clear();
}

@Override
Expand Down Expand Up @@ -981,7 +983,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
Expand Down