db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <Richard.Hille...@Sun.COM>
Subject Re: Returning NULL from a database-side Java function
Date Tue, 09 Oct 2007 17:19:06 GMT
Alan Burlison wrote:
> Rick Hillegas wrote:
>
>> It is hard to say where the NullPointerException originates. Could 
>> you post a reproducible test case and the full stack trace from 
>> derby.log? 
>
> Umm, it may be my bad, I have the following:
>
>     public static int iGoBang() {
>         int pop = 0 == 0 ? 1 : null;
>         return pop;
>     }
>
> Which compiles but blows up, whereas
>
>     public static int iGoBang() {
>         return null;
>     }
>
> won't even compile.  Because you can't assign null to a primitive type 
> - duh.  Which leaves 2 questions:
>
> 1. Why does int pop = 0 == 0 ? 1 : null; even compile?
I find that this does not compile when I use the jdk 1.4 javac but it 
succeeds when I use the Java 5 compiler. I'm guessing this is some sort 
of change introduced by autoboxing.
> 2. How *do* you return a database NULL from a function with a 
> primitive type as the return type? String isn't a primitive type.
You should be able to use a method which returns Integer instead of int. 
However, I am finding that Derby is not binding a function invocation to 
such a method. I have logged DERBY-3119 to track this issue. Hopefully 
someone will close the bug quickly, pointing out some pilot error on my 
part.

Regards,
-Rick




Mime
View raw message