Skip to main content

PL/Java in Postgres

Hi ,

Here is my first PL/Java which i have been compiled the documented PL/Java Example.

Step 1
======

bash-4.1$ vi HelloWorld.java
-bash-4.1$ pwd
/opt/PostgresPlus/9.1AS
-bash-4.1$ more HelloWorld.java 
     package com.mycompany.helloworld;

     public class HelloWorld
     { public static String helloWorld()
         {
                return "Hello World";
         }
     }

Step 2
======
-bash-4.1$ javac HelloWorld.java 
-bash-4.1$ mkdir -p com/mycompany/helloworld/
-bash-4.1$ cp HelloWorld.class com/mycompany/helloworld/
-bash-4.1$ jar cf helloworld.jar com/mycompany/helloworld/HelloWorld.class


Step 3
=====
edb=# SELECT sqlj.install_jar('file:///opt/PostgresPlus/9.1AS/helloworld.jar','helloworld', true);  
edb=# SELECT sqlj.set_classpath('public', 'helloworld');
edb=# SELECT * FROM helloworld();
 helloworld
-------------
 Hello World


--Dinesh

Will post more java stuff soon ... 

Comments