Fix JDBC connection not terminated after project rename

Connection getConnection was called outside of try resulting in not
closed connection.

Bug: Issue 14100
Change-Id: I60113bc072130830c177a28b91149e5036e40c52
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/DatabaseRenameHandler.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/DatabaseRenameHandler.java
index 57623ba..d19f792 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/DatabaseRenameHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/DatabaseRenameHandler.java
@@ -94,10 +94,10 @@
   private List<Change.Id> getChangeIdsFromReviewDb(Project.NameKey oldProjectKey, ReviewDb db)
       throws OrmException {
     List<Change.Id> changeIds = new ArrayList<>();
-    Connection conn = ((JdbcSchema) db).getConnection();
     String query =
         "select change_id from changes where dest_project_name ='" + oldProjectKey.get() + "';";
-    try (Statement stmt = conn.createStatement();
+    try (Connection conn = ((JdbcSchema) db).getConnection();
+        Statement stmt = conn.createStatement();
         ResultSet changes = stmt.executeQuery(query)) {
       while (changes != null && changes.next()) {
         Change.Id changeId = new Change.Id(changes.getInt(1));
@@ -153,8 +153,8 @@
       Project.NameKey newProjectKey,
       ReviewDb db)
       throws OrmException {
-    Connection conn = ((JdbcSchema) db).getConnection();
-    try (Statement stmt = conn.createStatement()) {
+    try (Connection conn = ((JdbcSchema) db).getConnection();
+        Statement stmt = conn.createStatement()) {
       conn.setAutoCommit(false);
       try {
         try {