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

Don't close the statement

上级 b023ccbf
......@@ -155,29 +155,26 @@ public class RunScript extends Tool {
* @return the last result set
*/
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();
ResultSet 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();
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();
}
} finally {
JdbcUtils.closeSilently(stat);
}
return rs;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论