db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stan Bradbury (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-1483) Java Function defined with a BIGINT parameter invokes the method with a signature of method(long) rather than method(Long)
Date Fri, 07 Jul 2006 14:21:30 GMT
    [ http://issues.apache.org/jira/browse/DERBY-1483?page=comments#action_12419722 ] 

Stan Bradbury commented on DERBY-1483:

Thanks Dan -
I find type resolution like this unpredictable (being relatively inexperienced with Java outside
of JDBC).  Is there a reference I can use to look-up how a Derby datatype will be resolved
in cases like this?  I would find it helpful to have this available in the manuals by either
including a table or a reference to the Java/JDBC spec.  

Or would a better method to include the full method signature in the 'EXTERNAL NAME" clause?
 I've seen no examples of anything other than the class and method name and it did not occur
to me that including the parameter type was allowed.  Addressing this in the documents would
also help non-Java expert-types to use this functionality.

I would like to spin-off an appropriate document enhancement for this to help others in using
this functionality.

> Java Function defined with a BIGINT parameter invokes the method with a signature of
method(long) rather than method(Long)
> --------------------------------------------------------------------------------------------------------------------------
>          Key: DERBY-1483
>          URL: http://issues.apache.org/jira/browse/DERBY-1483
>      Project: Derby
>         Type: Bug

>     Versions:
>     Reporter: Stan Bradbury
>     Priority: Minor

> Calling a function passing BIGINT to a method accepting Long fails with the message:
> ERROR 42X50: No method was found that matched the method call derbyJavaUtils.bigintToHexString(long),
tried all combinations of object and primitive types and any possible type conversion for
any  parameters the method call may have. The method might exist but it is not public and/or
static, or the parameter types are not method invocation convertible.
> The method needs to accept the primative type: long to work.  BIGINT as docuemented as
having a compile time type of java.lang.Long - this is why I expected the example method to
work: see the Reference manual: http://db.apache.org/derby/docs/10.1/ref/rrefsqlj30435.html.
> Example: define the function bigintToHexString to accept a BIGINT parameter (see below)
and reference the corresponding  java method bigintToHexString (shown below) that accepts
a Long.  Add the jarfile with the class to the DB, setup the database classpath and invoke
with the query shown.
>   >>> Java Class:
> import java.sql.*;
> public class derbyJavaUtils
> {
> // bigintToHexString
>     public static String bigintToHexString(Long myBigint)
>     {
> 	return myBigint.toHexString(myBigint.longValue());
>     }
> // bigintToHexString2 - this will work if used for the function
> public static String bigintToHexString2(long myBigint)
>     {
> 	Long myLong = null;
> 	return myLong.toHexString(myBigint);
>     }
> }
>  >> COMPILE IT AND JAR IT :  jar -cvf derbyJavaUtils.jar DerbyJavaUtils.class
> >> Setup the function as follows in a database:
>   .. CALL sqlj.install_jar( 'derbyJavaUtils.jar','APP.derbyJavaUtils',0);
>   .. CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath', 'APP.derbyJavaUtils');
>   .. CREATE FUNCTION app.bigintToHexString(hexString bigint)
> EXTERNAL NAME 'derbyJavaUtils.bigintToHexString'
>   === One possible test query:
> select  'C' ||  bigintToHexString2(CONGLOMERATENUMBER) ||  '.dat', TABLENAME, ISINDEX
>   where a.TABLEID = b.TABLEID
>   As mention in the code comments the method: bigintToHexString2 - will work if used
for the function

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message