提交 3efb1b28 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Close all instances of ResultSet in PgServerThread.initDb()

上级 469a69ea
......@@ -919,17 +919,18 @@ public class PgServerThread implements Runnable {
private void initDb() throws SQLException {
Statement stat = null;
ResultSet rs = null;
try {
synchronized (server) {
// better would be: set the database to exclusive mode
rs = conn.getMetaData().getTables(null, "PG_CATALOG", "PG_VERSION", null);
boolean tableFound = rs.next();
boolean tableFound;
try (ResultSet rs = conn.getMetaData().getTables(null, "PG_CATALOG", "PG_VERSION", null)) {
tableFound = rs.next();
}
stat = conn.createStatement();
if (!tableFound) {
installPgCatalog(stat);
}
rs = stat.executeQuery("select * from pg_catalog.pg_version");
try (ResultSet rs = stat.executeQuery("select * from pg_catalog.pg_version")) {
if (!rs.next() || rs.getInt(1) < 2) {
// installation incomplete, or old version
installPgCatalog(stat);
......@@ -941,17 +942,18 @@ public class PgServerThread implements Runnable {
}
}
}
}
stat.execute("set search_path = PUBLIC, pg_catalog");
HashSet<Integer> typeSet = server.getTypeSet();
if (typeSet.size() == 0) {
rs = stat.executeQuery("select oid from pg_catalog.pg_type");
try (ResultSet rs = stat.executeQuery("select oid from pg_catalog.pg_type")) {
while (rs.next()) {
typeSet.add(rs.getInt(1));
}
}
}
} finally {
JdbcUtils.closeSilently(stat);
JdbcUtils.closeSilently(rs);
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论