related with bug 39601: let it fail if ad_context info couldn't be created
authorAsier Lostalé <asier.lostale@openbravo.com>
Thu, 08 Nov 2018 10:57:00 +0100
changeset 34949 f55cbe0219f9
parent 34948 2ef2c5233cab
child 34950 847353facd72
related with bug 39601: let it fail if ad_context info couldn't be created
src-core/src/org/openbravo/database/SessionInfo.java
--- a/src-core/src/org/openbravo/database/SessionInfo.java	Thu Nov 08 10:47:32 2018 +0100
+++ b/src-core/src/org/openbravo/database/SessionInfo.java	Thu Nov 08 10:57:00 2018 +0100
@@ -119,21 +119,17 @@
   }
 
   private static void createAdContextInfoTable(Connection conn) {
-    // Create temporary table
-    PreparedStatement psCreate = null;
-    try {
-      StringBuffer sql = new StringBuffer();
-      sql.append("CREATE TEMPORARY TABLE AD_CONTEXT_INFO");
-      sql.append("(AD_USER_ID VARCHAR(32), ");
-      sql.append("  AD_SESSION_ID VARCHAR(32),");
-      sql.append("  PROCESSTYPE VARCHAR(60), ");
-      sql.append("  PROCESSID VARCHAR(32)) on commit preserve rows");
-      psCreate = getPreparedStatement(conn, sql.toString());
+    String sql = "CREATE TEMPORARY TABLE AD_CONTEXT_INFO" + //
+        "(AD_USER_ID VARCHAR(32), " + //
+        "  AD_SESSION_ID VARCHAR(32)," + //
+        "  PROCESSTYPE VARCHAR(60), " + //
+        "  PROCESSID VARCHAR(32)) on commit preserve rows";
+
+    try (PreparedStatement psCreate = getPreparedStatement(conn, sql)) {
       psCreate.execute();
-    } catch (Exception e) {
+    } catch (SQLException e) {
       log4j.error("Error initializating audit infrastructure", e);
-    } finally {
-      releasePreparedStatement(psCreate);
+      throw new IllegalStateException(e);
     }
   }