Skip to content

Commit 7155c58

Browse files
committed
fix: PrepareStatement
1. execute() do not affect added batches. 2. fix delete and insert updateCount. 3. fix executeBatch, use loop. 4. forbid multi statement.
1 parent 46df3d6 commit 7155c58

File tree

10 files changed

+249
-407
lines changed

10 files changed

+249
-407
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ target/
99
tests/data
1010
tests/compatibility/*.jar
1111
test-output
12+
.DS_Store

databend-jdbc/src/main/java/com/databend/jdbc/DatabendConnection.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ public static URI parseRouteHint(String routeHint) {
198198
if (routeHint == null || routeHint.isEmpty()) {
199199
return null;
200200
}
201-
URI target;
202201
try {
203202
if (routeHint.charAt(routeHint.length() - 1) != SPECIAL_CHAR) {
204203
return null;
@@ -228,14 +227,6 @@ private static void checkResultSet(int resultSetType, int resultSetConcurrency)
228227
}
229228
}
230229

231-
// Databend DOES NOT support transaction now
232-
private static void checkHoldability(int resultSetHoldability)
233-
throws SQLFeatureNotSupportedException {
234-
if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) {
235-
throw new SQLFeatureNotSupportedException("Result set holdability must be HOLD_CURSORS_OVER_COMMIT");
236-
}
237-
}
238-
239230
public static String getCopyIntoSql(String database, DatabendCopyParams params) {
240231
StringBuilder sb = new StringBuilder();
241232
sb.append("COPY INTO ");
@@ -297,7 +288,7 @@ synchronized private void unregisterStatement(DatabendStatement statement) {
297288
public PreparedStatement prepareStatement(String s)
298289
throws SQLException {
299290

300-
return this.prepareStatement(s, 0, 0);
291+
return this.prepareStatement(s, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
301292
}
302293

303294
@Override
@@ -435,7 +426,7 @@ public Statement createStatement(int resultSetType, int resultSetConcurrency)
435426
@Override
436427
public PreparedStatement prepareStatement(String s, int i, int i1)
437428
throws SQLException {
438-
DatabendPreparedStatement statement = new DatabendPreparedStatement(this, this::unregisterStatement, "test", s);
429+
DatabendPreparedStatement statement = new DatabendPreparedStatement(this, this::unregisterStatement, s);
439430
registerStatement(statement);
440431
return statement;
441432
}

0 commit comments

Comments
 (0)