提交 d5575609 authored 作者: Thomas Mueller's avatar Thomas Mueller

Don't close the statement

上级 b023ccbf
...@@ -155,29 +155,26 @@ public class RunScript extends Tool { ...@@ -155,29 +155,26 @@ public class RunScript extends Tool {
* @return the last result set * @return the last result set
*/ */
public static ResultSet execute(Connection conn, Reader reader) throws SQLException { public static ResultSet execute(Connection conn, Reader reader) throws SQLException {
// can not close the statement because we return a result set from it
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
ResultSet rs = null; ResultSet rs = null;
try { ScriptReader r = new ScriptReader(reader);
ScriptReader r = new ScriptReader(reader); while (true) {
while (true) { String sql = r.readStatement();
String sql = r.readStatement(); if (sql == null) {
if (sql == null) { break;
break; }
} if (sql.trim().length() == 0) {
if (sql.trim().length() == 0) { continue;
continue; }
} boolean resultSet = stat.execute(sql);
boolean resultSet = stat.execute(sql); if (resultSet) {
if (resultSet) { if (rs != null) {
if (rs != null) { rs.close();
rs.close(); rs = null;
rs = null;
}
rs = stat.getResultSet();
} }
rs = stat.getResultSet();
} }
} finally {
JdbcUtils.closeSilently(stat);
} }
return rs; return rs;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论