提交 588e4e05 authored 作者: noelgrandin's avatar noelgrandin

Issue 524: RunScript.execute does not close its Statement, patch from Gaul.

上级 6089c852
......@@ -31,6 +31,7 @@ Change Log
</li><li>Support 123L syntax as in Java; example: SELECT (2000000000L*2).
</li><li>Issue 520: Add support for sequence max value, min value and cycle, patch by Daniel Gredler.
</li><li>Issue 521: ScriptReader should implement Closeable
</li><li>Issue 524: RunScript.execute does not close its Statement, patch from Gaul.
</li></ul>
<h2>Version 1.3.174 (2013-10-19)</h2>
......
......@@ -157,23 +157,27 @@ public class RunScript extends Tool {
public static ResultSet execute(Connection conn, Reader reader) throws SQLException {
Statement stat = conn.createStatement();
ResultSet rs = null;
ScriptReader r = new ScriptReader(reader);
while (true) {
String sql = r.readStatement();
if (sql == null) {
break;
}
if (sql.trim().length() == 0) {
continue;
}
boolean resultSet = stat.execute(sql);
if (resultSet) {
if (rs != null) {
rs.close();
rs = null;
try {
ScriptReader r = new ScriptReader(reader);
while (true) {
String sql = r.readStatement();
if (sql == null) {
break;
}
if (sql.trim().length() == 0) {
continue;
}
boolean resultSet = stat.execute(sql);
if (resultSet) {
if (rs != null) {
rs.close();
rs = null;
}
rs = stat.getResultSet();
}
rs = stat.getResultSet();
}
} finally {
JdbcUtils.closeSilently(stat);
}
return rs;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论