[idx-operator-class] Close the connection after retrieving the table comments 3.0PR15Q4 3.0PR16Q1
authorAugusto Mauch <augusto.mauch@openbravo.com>
Mon, 24 Aug 2015 09:58:49 +0200
changeset 634 2ab940db1994
parent 633 a052282baa1a
child 635 f8106033817e
[idx-operator-class] Close the connection after retrieving the table comments
src/org/apache/ddlutils/platform/oracle/Oracle8Builder.java
--- a/src/org/apache/ddlutils/platform/oracle/Oracle8Builder.java	Wed Aug 19 09:11:10 2015 +0200
+++ b/src/org/apache/ddlutils/platform/oracle/Oracle8Builder.java	Mon Aug 24 09:58:49 2015 +0200
@@ -708,9 +708,10 @@
    */
   private String getCommentOfTable(String tableName) {
     String tableComment = null;
+    Connection con = null;
     try {
       PreparedStatement st = null;
-      Connection con = getPlatform().getDataSource().getConnection();
+      con = getPlatform().getDataSource().getConnection();
 
       st = con
           .prepareStatement("SELECT comments FROM all_tab_comments WHERE UPPER(table_name) = ?");
@@ -720,7 +721,14 @@
         tableComment = rs.getString(1);
       }
     } catch (SQLException e) {
-      _log.error("Error while getting the comment of the table " + tableName, e);
+    } finally {
+      if (con != null) {
+        try {
+          con.close();
+        } catch (SQLException e) {
+          _log.error("Error while closing the connection", e);
+        }
+      }
     }
     return tableComment;
   }