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