[Pljava-dev] User defined Function

From: rossel at peranto(dot)de (Andreas Rossel)
To:
Subject: [Pljava-dev] User defined Function
Date: 2008-02-11 10:10:49
Message-ID: 001201c86c96$60e713f0$a5c8a8c0@perantoarr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Hello,

i?m new to pljava and the first I tried was creating a stored procedure in pljava.
But it doesnt work.

Here a quick walkthrough of my code:

There is a package test with my (one and only) Java class TestPLJava.
It has a main routine (which does nothing, but i seem to need it to generate the JAR)
and my desired method ?einParameter? which should take one integer parameter and return a string.
Here it is:

package test;
public class TestPLJava {
public static java.lang.String einParameter(int in) {
return "ein Parameter "+in;
}
public static void main(String[] args) {
;
}
}

I declare / map the method within a SQLJDeploymentDescriptor which is:

SQLActions[] = {
"BEGIN INSTALL
create function javatest.testeiner(integer)
returns character varying
as 'test.TestPLJava.einParameter'
language java;
select sqlj.set_classpath('javatest', 'PLJavaTest');
END INSTALL",
"BEGIN REMOVE
DROP FUNCTION javatest.testeiner(integer);
END REMOVE"
}

I generate the JAR (with eclipse, my Java-IDE ? but this shouldn?t matter?) and install it with:

select sqlj.install_jar('file:///c:/myDirectory/PLJavaTest.jar', 'PLJavaTest', true);

And so far it works fine. In the pgAdmin tool I could find a function ?testeiner? which points to my java method.
Even the classpath is set.

But if I trie to call the function i get an error message. The command:

select testeiner(1);

Results in:

ERROR: function testeiner(integer) does not exist
SQL Status:42883
Hinweis:No function matches the given name and argument types. You may need to add explicit type casts.
Zeichen:8

And calling:

select javatest.testeiner(1);

Returns:

ERROR: java.lang.ClassNotFoundException: test.TestPLJave
SQL Status:XX000

I am working with a PostgreSQL Database 8.2 on a Windows Server 2003 with Java 1.6.0_03.

Thanks in advance,

Andreas


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20080211/7110db1d/attachment.html>

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Andreas Rossel 2008-02-14 12:07:21 [Pljava-dev] User defined Function
Previous Message Kris Jurka 2008-02-07 00:31:53 [Pljava-dev] PLJAVA installation problems