You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by da...@apache.org on 2018/08/08 16:59:04 UTC
svn commit: r1837662 -
/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Author: dazeydev
Date: Wed Aug 8 16:59:04 2018
New Revision: 1837662
URL: http://svn.apache.org/viewvc?rev=1837662&view=rev
Log:
OPENJPA-2745: Clean up try-catch implementation for DB2Dictionary
Modified:
openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java?rev=1837662&r1=1837661&r2=1837662&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DB2Dictionary.java Wed Aug 8 16:59:04 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;
- }
}
}