Skip to content

Commit 6fef328

Browse files
committed
replaced 9+ API with own code
1 parent 6cbce88 commit 6fef328

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/PreparedStatementImpl.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,21 +403,29 @@ public ResultSetMetaData getMetaData() throws SQLException {
403403

404404
private static final Pattern REPLACE_Q_MARK_PATTERN = Pattern.compile("(\"[^\"]*\"|`[^`]*`|'[^']*')|(\\?)");
405405

406-
public static String replaceQuestionMarks(String sql, String replacement) {
406+
public static String replaceQuestionMarks(String sql, final String replacement) {
407407
Matcher matcher = REPLACE_Q_MARK_PATTERN.matcher(sql);
408408

409409
StringBuilder result = new StringBuilder();
410410

411+
int lastPos = 0;
411412
while (matcher.find()) {
412-
if (matcher.group(1) != null) {
413+
String text;
414+
if ((text = matcher.group(1)) != null) {
413415
// Quoted string — keep as-is
414-
matcher.appendReplacement(result, Matcher.quoteReplacement(matcher.group(1)));
416+
String str = Matcher.quoteReplacement(text);
417+
result.append(sql, lastPos, matcher.start()).append(str);
418+
lastPos = matcher.end();
415419
} else if (matcher.group(2) != null) {
416420
// Question mark outside quotes — replace it
417-
matcher.appendReplacement(result, Matcher.quoteReplacement(replacement));
421+
String str = Matcher.quoteReplacement(replacement);
422+
result.append(sql, lastPos, matcher.start()).append(str);
423+
lastPos = matcher.end();
418424
}
419425
}
420-
matcher.appendTail(result);
426+
427+
// Add rest of the `sql`
428+
result.append(sql, lastPos, sql.length());
421429
return result.toString();
422430
}
423431

jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataImpl.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,9 +1414,4 @@ public long getMaxLogicalLobSize() throws SQLException {
14141414
public boolean supportsRefCursors() throws SQLException {
14151415
return false;
14161416
}
1417-
1418-
@Override
1419-
public boolean supportsSharding() throws SQLException {
1420-
return false;
1421-
}
14221417
}

jdbc-v2/src/test/java/com/clickhouse/jdbc/PreparedStatementTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.time.LocalDateTime;
2323
import java.time.ZoneId;
2424
import java.time.temporal.ChronoUnit;
25-
import java.time.temporal.TemporalUnit;
2625
import java.util.ArrayList;
2726
import java.util.Arrays;
2827
import java.util.Collection;

0 commit comments

Comments
 (0)