db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: should Clob.getSubstring() allow length of 0?
Date Sat, 15 Jul 2006 04:33:51 GMT
Hi Kathy,

On Jul 14, 2006, at 6:46 PM, Kathey Marsden wrote:

> Lance J. Andersen wrote:
>
>> Hi Kathy,
>>
>> I would probably expect a  SQLException to be thrown in this case  
>> or I guess you could return nothing.
>>
> I will assume then that the Derby behavior  is correct and won't  
> file a bug.
> Thank you for the clarification but I don't think your comment was  
> either necessary or appropriate.
>
> In the DDLUtils code, they just had the generic code:  value =  
> clob.getSubString(1,  (int)clob.length());  to handle all non-null  
> Clobs.
> The fix was to add in an extra branch to handle zero length Clobs  
> which they were more than happy to do although it made their code  
> look a little messier.

You can always work around odd code on the other side of an  
incompletely defined interface. But you probably have code on the  
Derby side that also checks for the clob.length() == 0 and take some  
extraordinary action.

So much easier for neither side to check for zero length and let the  
natural boundary condition happen.

Craig
>
> This was the change to work around the SQLException.
>
> +                            else if (clob.length() == 0)
> +                               {
> +                                       value = "";
> +                               }
>                        else
>                        {
>                            value = clob.getSubString(1,  (int) 
> clob.length());
>
> Kathey

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message