Skip to content

Commit

Permalink
Added a new option throwWarning to ScriptRunner. Related to mybatis/m…
Browse files Browse the repository at this point in the history
  • Loading branch information
harawata committed May 11, 2016
1 parent 800f852 commit b93256a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/org/apache/ibatis/jdbc/ScriptRunner.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2009-2015 the original author or authors.
* Copyright 2009-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,7 @@
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;

/**
Expand All @@ -37,6 +38,7 @@ public class ScriptRunner {
private Connection connection;

private boolean stopOnError;
private boolean throwWarning;
private boolean autoCommit;
private boolean sendFullScript;
private boolean removeCRs;
Expand All @@ -56,6 +58,10 @@ public void setStopOnError(boolean stopOnError) {
this.stopOnError = stopOnError;
}

public void setThrowWarning(boolean throwWarning) {
this.throwWarning = throwWarning;
}

public void setAutoCommit(boolean autoCommit) {
this.autoCommit = autoCommit;
}
Expand Down Expand Up @@ -227,6 +233,12 @@ private void executeStatement(String command) throws SQLException {
}
if (stopOnError) {
hasResults = statement.execute(sql);
if (throwWarning) {
SQLWarning warning = statement.getWarnings();
if (warning != null) {
throw warning;
}
}
} else {
try {
hasResults = statement.execute(sql);
Expand Down

0 comments on commit b93256a

Please sign in to comment.