db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kathey Marsden <kmarsdende...@sbcglobal.net>
Subject Re: The tutorial on migrating DB to derby
Date Wed, 14 Jun 2006 23:12:48 GMT
Thomas Dudziak wrote:

>
> seems to be ok according to the Clob javadocs
> (http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Clob.html#getSubString(long,%20int)),

>
> right ? A string is only returned (and getSubString called) if the
> length of the clob is within int range, so length() seems to return a
> value <= 0 ?
>
The problem was just that  ddlutils was not handling the case where the 
lob length was 0, but it was not null (an empty string was in the CLOB 
column)
The hack of a patch below got me going.

Thanks so, so, much to DdlUtils and to Jean for the great tutorial to 
get me going in a hurry.
I used DdlUtils to migrate data when trying to recover a database for a 
user that had a corrupted database today.
(some business about removing a pesky db.lck file that wouldn't let them 
boot their database).
All the user's  backups were corrupt and  we don't have import/export 
for lobs yet (DERBY-378),
so I was completely stuck until I found DdlUtils which I found easy to 
use and really saved my day.


Index: src/java/org/apache/ddlutils/platform/PlatformImplBase.java
===================================================================
--- src/java/org/apache/ddlutils/platform/PlatformImplBase.java 
(revision 414353)
+++ src/java/org/apache/ddlutils/platform/PlatformImplBase.java (working 
copy)
@@ -1956,6 +1956,10 @@
                        {
                            value = clob;
                        }
+                            else if (clob.length() == 0)
+                               {
+                                       value = "";
+                               }
                        else
                        {
                            value = clob.getSubString(1l, 
(int)clob.length());
@@ -1968,6 +1972,10 @@
                        {
                            value = blob;
                        }
+                               else if (blob.length() == 0)
+                               {
+                                       value = "";
+                               }
                        else
                        {
                            value = blob.getBytes(1l, (int)blob.length());



Mime
View raw message