openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dazey...@apache.org
Subject svn commit: r1837659 - /openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Date Wed, 08 Aug 2018 16:57:26 GMT
Author: dazeydev
Date: Wed Aug  8 16:57:26 2018
New Revision: 1837659

URL: http://svn.apache.org/viewvc?rev=1837659&view=rev
Log:
OPENJPA-2745: Clean up try-catch implementation for DB2Dictionary

Modified:
    openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java

Modified: openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=1837659&r1=1837658&r2=1837659&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
(original)
+++ openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Wed Aug  8 16:57:26 2018
@@ -1024,30 +1024,22 @@ public class DB2Dictionary
             return (byte[]) rs.getObject(column);
         }
 
-        // At this point we don't have any idea if the DB2 column was defined as
-        //     a blob or if it was defined as CHAR for BIT DATA.
-        // First try as a blob, if that doesn't work, then try as CHAR for BIT DATA
-        // If that doesn't work, then go ahead and throw the first exception
-        try {
-            Blob blob = getBlob(rs, column);
-            if (blob == null) {
-                return null;
-            }
-            
-            int length = (int) blob.length();
-            if (length == 0) {
-                return null;
-            }
-            
-            return blob.getBytes(1, length);
-        }
-        catch (SQLException e) {
-            try {
+        int type = rs.getMetaData().getColumnType(column);
+        switch (type) {
+            case Types.BLOB:
+                Blob blob = getBlob(rs, column);
+                if (blob == null) {
+                    return null;
+                }
+
+                int length = (int) blob.length();
+                if (length == 0) {
+                    return null;
+                }
+                return blob.getBytes(1, length);
+            case Types.BINARY:
+            default:
                 return rs.getBytes(column);
-            }
-            catch (SQLException e2) {
-                throw e;                
-            }
         }
     }
 



Mime
View raw message