cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1343597 - /cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
Date Tue, 29 May 2012 08:27:47 GMT
Author: ay
Date: Tue May 29 08:27:47 2012
New Revision: 1343597

URL: http://svn.apache.org/viewvc?rev=1343597&view=rev
Log:
support other DBs for CXF-4249

Modified:
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java?rev=1343597&r1=1343596&r2=1343597&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
(original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
Tue May 29 08:27:47 2012
@@ -138,8 +138,12 @@ public class RMTxStore implements RMStor
         "SELECT MSG_NO, SEND_TO, CONTENT FROM {0} WHERE SEQ_ID = ?";
     private static final String ALTER_TABLE_STMT_STR =
         "ALTER TABLE {0} ADD {1} {2}";
+    // create_schema may not work for several reasons, if so, create one manually
     private static final String CREATE_SCHEMA_STMT_STR = "CREATE SCHEMA {0}";
-    private static final String SET_CURRENT_SCHEMA_STMT_STR = "SET CURRENT SCHEMA {0}";
+    // given the schema, try these standard statements to switch to the schema
+    private static final String[] SET_SCHEMA_STMT_STRS = {"SET SCHEMA {0}",
+                                                          "SET CURRENT_SCHEMA = {0}",
+                                                          "ALTER SESSION SET CURRENT_SCHEMA
= {0}"};
     
     private static final String DERBY_TABLE_EXISTS_STATE = "X0Y32";
     private static final int ORACLE_TABLE_EXISTS_CODE = 955;
@@ -727,15 +731,23 @@ public class RMTxStore implements RMStor
             stmt.executeUpdate(MessageFormat.format(CREATE_SCHEMA_STMT_STR, 
                                                     schemaName));
         } catch (SQLException ex) {
-            // pass through to assume it is already created
+            // assume it is already created or no authorization is provided (create one manually)
         }
         stmt.close();
         stmt = connection.createStatement();
-        try {
-            stmt.executeUpdate(MessageFormat.format(SET_CURRENT_SCHEMA_STMT_STR, 
-                                                    schemaName));
-        } catch (SQLException ex) {
-            throw ex;
+        SQLException ex0 = null;
+        for (int i = 0; i < SET_SCHEMA_STMT_STRS.length; i++) {
+            try {
+                stmt.executeUpdate(MessageFormat.format(SET_SCHEMA_STMT_STRS[i], schemaName));
+                break;
+            } catch (SQLException ex) {
+                ex.setNextException(ex0);
+                ex0 = ex;
+                if (i == SET_SCHEMA_STMT_STRS.length - 1) {
+                    throw ex0;
+                }
+                // continue
+            }
         }
         stmt.close();
     }



Mime
View raw message