Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,15 @@ DatabaseType getDatabaseType() {
* @throws SQLException : Exception while executing the script.
*/
public void executeScript(InputStream scriptInputStream) throws SQLException {
try {
try (BufferedReader scriptReader =
new BufferedReader(
new InputStreamReader(Objects.requireNonNull(scriptInputStream), UTF_8))) {
List<String> scriptLines = scriptReader.lines().toList();
runWithinTransaction(
connection -> {
try (Statement statement = connection.createStatement();
BufferedReader reader =
new BufferedReader(
new InputStreamReader(Objects.requireNonNull(scriptInputStream), UTF_8))) {
try (Statement statement = connection.createStatement()) {
StringBuilder sqlBuffer = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
for (String line : scriptLines) {
line = line.trim();
if (!line.isEmpty() && !line.startsWith("--")) { // Ignore empty lines and comments
sqlBuffer.append(line).append("\n");
Expand All @@ -110,16 +109,10 @@ public void executeScript(InputStream scriptInputStream) throws SQLException {
}
}
return true;
} catch (IOException e) {
throw new RuntimeException(e);
}
});
} finally {
try {
scriptInputStream.close();
} catch (IOException e) {
LOGGER.error("Failed to close input stream: {}", e.getMessage());
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}

Expand Down
Loading