This is an automated email from the ASF dual-hosted git repository. zhangliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push: new 9b8700ac66b Remove useless SQLScriptUtils.executeBatch() (#35253) 9b8700ac66b is described below commit 9b8700ac66b67a115f0ce68873b144939d1d5b34 Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Sat Apr 26 11:05:37 2025 +0800 Remove useless SQLScriptUtils.executeBatch() (#35253) * Remove useless SQLScriptUtils.executeBatch() * Remove useless SQLScriptUtils.executeBatch() --- .../env/container/atomic/util/SQLScriptUtils.java | 38 ---------------------- 1 file changed, 38 deletions(-) diff --git a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/util/SQLScriptUtils.java b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/util/SQLScriptUtils.java index a75f48d17d8..4d90c56f9cd 100644 --- a/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/util/SQLScriptUtils.java +++ b/test/e2e/env/src/test/java/org/apache/shardingsphere/test/e2e/env/container/atomic/util/SQLScriptUtils.java @@ -42,8 +42,6 @@ import java.sql.Statement; @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class SQLScriptUtils { - private static final int BATCH_SIZE = 100; - /** * Execute SQL script. * @@ -71,42 +69,6 @@ public final class SQLScriptUtils { } } - /** - * Execute SQL script. - * - * @param dataSource data source - * @param scriptFilePath script file path - */ - @SneakyThrows({SQLException.class, IOException.class}) - public static void executeBatch(final DataSource dataSource, final String scriptFilePath) { - try ( - Connection connection = dataSource.getConnection(); - Reader reader = getReader(scriptFilePath)) { - Statement statement = connection.createStatement(); - ScriptReader r = new ScriptReader(reader); - r.setSkipRemarks(true); - int count = 0; - while (true) { - String sql = r.readStatement(); - if (null == sql) { - break; - } - if (StringUtils.isBlank(sql)) { - continue; - } - statement.addBatch(sql); - count++; - if (0 == count % BATCH_SIZE) { - statement.executeBatch(); - statement.clearBatch(); - } - } - if (0 != count % BATCH_SIZE) { - statement.executeBatch(); - } - } - } - private static Reader getReader(final String scriptFilePath) throws FileNotFoundException { InputStream resourceAsStream = SQLScriptUtils.class.getClassLoader().getResourceAsStream(StringUtils.removeStart(scriptFilePath, "/")); return resourceAsStream == null ? new FileReader(scriptFilePath) : new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));