db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel John Debrunner <...@apache.org>
Subject Re: Installing and Using Java Procedures.
Date Thu, 24 Jan 2008 21:23:41 GMT
Briggs wrote:
> I'm having a bit of a problem installing a java procedure in derby
> (10.3).  I thought I understood what I could do with them but now...
> 
> I have created a simple "hello world" procedure:
> 
> --------------
> 
> package derby.proc;
> 
> public class HelloWorldProcedure {
>    public static String helloWorld(final String name) {
>       return "hello " + name;
>    }
> }
> 
> --------------
> 
> Then created a jar file called DerbyProcs.jar in my temp directory
> (with the above class).
> 
> Then I run the following commands:
> 
> CALL SQLJ.install_jar('c:\tmp\DerbyProcs.jar', 'APP.DERBY_PROCS', 0);
> 
> CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath','APP.DERBY_PROCS');
> 
> CREATE PROCEDURE APP.HELLO_WORLD(
>    IN NAME VARCHAR(20),
>    OUT HELLO_YOU VARCHAR(30)
> )
> PARAMETER STYLE JAVA
> READS SQL DATA
> LANGUAGE JAVA
> EXTERNAL NAME  'derby.proc.HelloWorldProcedure.helloWorld';
> 
> 
> -- CALL THE PROC
> 
> CALL APP.HELLO_WORLD('world');
> 
> 
> The result I get is:
> 
> Error code 30000, SQL state 42Y03: 'APP.HELLO_WORLD' is not recognized
> as a function or procedure.
> Line 13, column 1
> 
> 
> What am I missing? Am I wrong on what I am expecting to happen?

You defined an procedure that takes two arguments, but then only passed 
one, so no matching procedure will be found. Then as your later e-mail 
says this needs to be a function, OUT parameters are returned using one 
element arrays in the Java method's argument list.

See:

http://wiki.apache.org/db-derby/DerbySQLroutines

this page has a list of useful topics:

http://wiki.apache.org/db-derby/HintsAndTips

Dan.

Mime
View raw message