7.9.3 Using PL/Java

Table of Contents Previous Next



To create a PL/Java program, you must first create a Java class that contains at least one static method, and then you must compile that class into a .class or .jar file. Next, you declare the Java function within SQL using the CREATE FUNCTION command. The CREATE FUNCTION command gives a SQL name to the function and associates the compiled class (and method name) with that function name.
For example, the following CREATE FUNCTION statement creates a function names getsysprop:
When invoked, getsysprop will execute the getProperty (static) method defined within the java.lang.System class.
4.
Open the edb-psql client, and install the jar file with the following command:
To confirm that the jar file has been loaded correctly, perform a SELECT statement on the sqlj.jar_entry and sqlj.jar_repository tables.
The sqlj.classpath_entry table will now include an entry for the helloworld class file.


Table of Contents Previous Next