Mmmmmm, I was really needing to do this without having to load my own Java classes as that isn't practical in my case.
To, On 19/12/2013 13:20, Knut Anders Hatlen wrote:
Tim Dudgeon <[email protected]> writes:I'm struggling with getting a function working that uses a Java static method that uses varargs. I understand this should work with 10.10.1.1? I create function like this: CREATE FUNCTION FORMAT_CPD_CODE ( FORMAT VARCHAR(100), VAL INT ... ) RETURNS VARCHAR(20) PARAMETER STYLE DERBY NO SQL LANGUAGE JAVA EXTERNAL NAME 'java.lang.String.format' and use it like this: values(FORMAT_CPD_CODE('XYZ%08d', 123)) But I get error: java.sql.SQLSyntaxErrorException: No method was found that matched the method call java.lang.String.format(java.lang.String, int...), 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. Any suggestions on how to get this working?Hi Tim, Derby's method resolution currently requires the types in the signature to match exactly. That is, it doesn't accept Object for an INT parameter; it has to be int or java.lang.Integer. I think it should work if you create a thin wrapper method around String.format() with the correct signature. Something like this: public static String format(String format, Integer... args) { return String.format(format, (Object[]) args); } And then point to the wrapper method in the CREATE FUNCTION call. Hope this helps,
