openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wisnes...@apache.org
Subject svn commit: r525572 - in /incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql: DB2Dictionary.java DBDictionary.java SQLExceptions.java
Date Wed, 04 Apr 2007 18:45:41 GMT
Author: wisneskid
Date: Wed Apr  4 11:45:40 2007
New Revision: 525572

URL: http://svn.apache.org/viewvc?view=rev&rev=525572
Log:
changes for OPENJPA-184.Appending DB2Diagnosable information to the exception.No logging done.

Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLExceptions.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?view=diff&rev=525572&r1=525571&r2=525572
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Wed Apr  4 11:45:40 2007
@@ -442,4 +442,39 @@
             append(" ").append(rowClause);
         return buf;
     }
-}
+
+    /** Append exception information from SQLCA to the exsisting 
+     *  exception meassage
+     */
+    public String appendExtendedExceptionMsg(String msg, SQLException sqle){
+       final String GETSQLCA ="getSqlca";
+       String exceptionMsg = new String();
+       try {
+            Method sqlcaM2 = sqle.getNextException().getClass()
+                             .getMethod(GETSQLCA,null);
+            Object sqlca = sqlcaM2.invoke(sqle.getNextException(),
+                                          new Object[] {});
+            Method  getSqlErrpMethd = sqlca.getClass().
+            getMethod("getSqlErrp", null);
+            Method  getSqlWarnMethd = sqlca.getClass().
+            getMethod("getSqlWarn", null);
+            Method  getSqlErrdMethd = sqlca.getClass().
+            getMethod("getSqlErrd", null);
+            exceptionMsg = exceptionMsg.concat( "SQLCA OUTPUT" + 
+                    "[Errp=" +getSqlErrpMethd.invoke(sqlca,new Object[]{})
+                    + ", Errd=" + Arrays.toString((int[])
+                            (getSqlErrdMethd.invoke(sqlca, new Object[]{}))));
+            String Warn = new String((char[])getSqlWarnMethd.
+                    invoke(sqlca, new Object[]{}));
+            if(Warn.trim().length() != 0)
+                exceptionMsg = exceptionMsg.concat(", Warn=" +Warn + "]" ); 
+            else
+                exceptionMsg = exceptionMsg.concat( "]" ); 
+            msg = msg.concat(exceptionMsg);
+            return msg;
+        } catch (Throwable t) {
+            return sqle.getMessage();
+        }
+    }
+
+   }
\ No newline at end of file

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?view=diff&rev=525572&r1=525571&r2=525572
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed Apr  4 11:45:40 2007
@@ -2470,7 +2470,14 @@
         buf.append(getTypeName(type));
         buf.append(post);
     }
-
+    
+    /** Append any database specific exception message to 
+     *  the exsisting exception message
+     */
+     public String appendExtendedExceptionMsg(String msg, SQLException sqle) {
+         return msg; 
+     }
+    
     ///////////
     // DDL SQL
     ///////////

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLExceptions.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLExceptions.java?view=diff&rev=525572&r1=525571&r2=525572
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLExceptions.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLExceptions.java
Wed Apr  4 11:45:40 2007
@@ -87,6 +87,7 @@
         Object failed, DBDictionary dict) {
         if (msg == null)
             msg = se.getClass().getName();
+        msg = dict.appendExtendedExceptionMsg(msg,se);
         SQLException[] ses = getSQLExceptions(se);
         if (dict == null)
             return new StoreException(msg).setFailedObject(failed).



Mime
View raw message