db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r414641 - /db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
Date Thu, 15 Jun 2006 17:43:10 GMT
Author: tomdz
Date: Thu Jun 15 10:43:09 2006
New Revision: 414641

URL: http://svn.apache.org/viewvc?rev=414641&view=rev
Log:
Added special handling of Clobs/Blobs of size 0 as suggested by Kathey Marsden

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java?rev=414641&r1=414640&r2=414641&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java Thu Jun
15 10:43:09 2006
@@ -1952,26 +1952,58 @@
 		    case Types.CLOB:
 		        Clob clob = resultSet.getClob(columnName);
 
-		        if ((clob == null) || (clob.length() > Integer.MAX_VALUE))
-		        {
-		            value = clob;
-		        }
-		        else
-		        {
-		            value = clob.getSubString(1l, (int)clob.length());
-		        }
+                if (clob == null)
+                {
+                    value = null;
+                }
+                else
+                {
+                    long length = clob.length();
+    
+    		        if (length > Integer.MAX_VALUE)
+    		        {
+    		            value = clob;
+    		        }
+                    else if (length == 0)
+                    {
+                        // the javadoc is not clear about whether Clob.getSubString
+                        // can be used with a substring length of 0
+                        // thus we do the safe thing and handle it ourselves
+                        value = "";
+                    }
+    		        else
+    		        {
+    		            value = clob.getSubString(1l, (int)length);
+    		        }
+                }
 		        break;
 		    case Types.BLOB:
 		        Blob blob = resultSet.getBlob(columnName);
 
-		        if ((blob == null) || (blob.length() > Integer.MAX_VALUE))
-		        {
-		            value = blob;
-		        }
-		        else
-		        {
-		            value = blob.getBytes(1l, (int)blob.length());
-		        }
+                if (blob == null)
+                {
+                    value = null;
+                }
+                else
+                {
+                    long length = blob.length();
+    
+    		        if (length > Integer.MAX_VALUE)
+    		        {
+    		            value = blob;
+    		        }
+                    else if (length == 0)
+                    {
+                        // the javadoc is not clear about whether Blob.getBytes
+                        // can be used with for 0 bytes to be copied
+                        // thus we do the safe thing and handle it ourselves
+                        value = new byte[0];
+                    }
+    		        else
+    		        {
+    		            value = blob.getBytes(1l, (int)length);
+    		        }
+                }
 		        break;
 		    case Types.ARRAY:
 		        value = resultSet.getArray(columnName);



Mime
View raw message