agora inbox for pljava-dev@postgresql.org
help / color / mirror / Atom feed[Pljava-dev] User defined Function
6+ messages / 0 participants
[nested] [flat]
* [Pljava-dev] User defined Function
@ 2008-02-11 10:10
0 siblings, 1 reply; 6+ messages in thread
From: @ 2008-02-11 10:10 UTC (permalink / raw)
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;
^ permalink raw reply [nested|flat] 6+ messages in thread
* [Pljava-dev] User defined Function
@ 2008-02-14 12:07
0 siblings, 1 reply; 6+ messages in thread
From: @ 2008-02-14 12:07 UTC (permalink / raw)
Hi again,
I found a workaround to my problem.
If I put my method in a second class beside the class with the main-routine it works! :D
Is this the way it should be?
Regards,
Andreas
^ permalink raw reply [nested|flat] 6+ messages in thread
* [Pljava-dev] User defined Function
@ 2008-02-15 23:51
parent:
0 siblings, 1 reply; 6+ messages in thread
From: @ 2008-02-15 23:51 UTC (permalink / raw)
On Mon, 11 Feb 2008, Andreas Rossel wrote:
> But if I trie to call the function i get an error message. The command:
>
> select testeiner(1);
>
> ERROR: function testeiner(integer) does not exist
This is because the javatest schema is not in your search_path. PG will
only look for functions in the schemas you tell it to.
http://www.postgresql.org/docs/8.3/static/ddl-schemas.html#DDL-SCHEMAS-PATH
Kris Jurka
^ permalink raw reply [nested|flat] 6+ messages in thread
* [Pljava-dev] User defined Function
@ 2008-02-15 23:58
parent:
0 siblings, 1 reply; 6+ messages in thread
From: @ 2008-02-15 23:58 UTC (permalink / raw)
On Thu, 14 Feb 2008, Andreas Rossel wrote:
> I found a workaround to my problem. If I put my method in a second class
> beside the class with the main-routine it works! :D
>
> Is this the way it should be?
>
No, that's not right. Perhaps your jar file isn't being created
correctly? Your original description stated that you needed to add a main
method to be able to create the jar in the first place which sounds
suspicious. Perhaps verifying it with "jar -tf myjarfile.jar" and
checking to see that everything is there would tell us something.
Kris Jurka
^ permalink raw reply [nested|flat] 6+ messages in thread
* [Pljava-dev] User defined Function
@ 2008-02-18 11:48
parent:
0 siblings, 0 replies; 6+ messages in thread
From: @ 2008-02-18 11:48 UTC (permalink / raw)
:~\-----Urspr?ngliche Nachricht-----
:~\Von: Kris Jurka [mailto:books at ejurka.com]
:~\Gesendet: Samstag, 16. Februar 2008 00:59
:~\
:~\On Thu, 14 Feb 2008, Andreas Rossel wrote:
:~\
:~\> I found a workaround to my problem. If I put my method in a second class
:~\> beside the class with the main-routine it works! :D
:~\>
:~\> Is this the way it should be?
:~\>
:~\
:~\No, that's not right. Perhaps your jar file isn't being created
:~\correctly? Your original description stated that you needed to add a main
:~\method to be able to create the jar in the first place which sounds
:~\suspicious. Perhaps verifying it with "jar -tf myjarfile.jar" and
:~\checking to see that everything is there would tell us something.
:~\
You found the prime suspect!
I tried to create the JAR without a main() by deleting the line:
Main-Class: test
out of my JAR-manifest. But doing so produced an error. Now I just deleted the classname and it works.
Thanks a lot.
Andreas
^ permalink raw reply [nested|flat] 6+ messages in thread
* [Pljava-dev] User defined Function
@ 2008-02-18 12:05
parent:
0 siblings, 0 replies; 6+ messages in thread
From: @ 2008-02-18 12:05 UTC (permalink / raw)
:~\-----Urspr?ngliche Nachricht-----
:~\Von: Kris Jurka [mailto:books at ejurka.com]
:~\Gesendet: Samstag, 16. Februar 2008 00:52
:~\
:~\On Mon, 11 Feb 2008, Andreas Rossel wrote:
:~\
:~\> But if I trie to call the function i get an error message. The command:
:~\>
:~\> select testeiner(1);
:~\>
:~\> ERROR: function testeiner(integer) does not exist
:~\
:~\This is because the javatest schema is not in your search_path. PG will
:~\only look for functions in the schemas you tell it to.
:~\
:~\http://www.postgresql.org/docs/8.3/static/ddl-schemas.html#DDL-SCHEMAS-PATH
:~\
OK, now I know the difference between sqlj.set_classpath() and search_path ...
Thanks for the hint.
Andreas
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2008-02-18 12:05 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-02-11 10:10 [Pljava-dev] User defined Function
2008-02-15 23:51 `
2008-02-18 12:05 `
2008-02-14 12:07 [Pljava-dev] User defined Function
2008-02-15 23:58 `
2008-02-18 11:48 `
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox