agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
Subject: [Pljava-dev] User defined Function
Date: Mon, 11 Feb 2008 11:10:49 +0100
Message-ID: <001201c86c96$60e713f0$a5c8a8c0@perantoarr> (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;



view thread (6+ messages)  latest in thread

Message-ID: <001201c86c96$60e713f0$a5c8a8c0@perantoarr>
Permalink:  ../001201c86c96$60e713f0$a5c8a8c0@perantoarr/
Also on:    postgresql.org/message-id/001201c86c96$60e713f0$a5c8a8c0@perantoarr

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pljava-dev@postgresql.org
  Subject: Re: [Pljava-dev] User defined Function
  In-Reply-To: <001201c86c96$60e713f0$a5c8a8c0@perantoarr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox