Top
Symfoware Server V12.1.0 Operation Guide
FUJITSU Software

7.2.4 Registering Java Functions

This section explains how to register Java functions and store Java applications.

This procedure must be performed each time a Java function is created.

Registering Java Functions

  1. Connect to the database

    As the instance administrator, connect to the database that corresponds to the container that was created using the psql command or pgAdmin.

  2. Register the function in the database

    Java functions run on sessions that are not dependent on the caller session. To operate a Java function using the caller session, use the SET statement to set the plextjava.separate_session parameter to "off" and then register it.

    SET plextjava.separate_session=off

    This section explains the CREATE FUNCTION statement used when registering a function in the database.

    Syntax:

    CREATE  [ OR  REPLACE ]  FUNCTION
        name  ( [ IN ] argtype [, ...] )
        [ RETURNS  rettype ]
        AS  'definition'
        LANGUAGE  lang_name
    name

    Specify the name of the Java function.

    The name of the Java function does not need to match the name of the Java application method.

    A qualified schema name can be used. Create the schema in advance.

    argtype

    Specify the data type of the Java function argument.

    rettype

    Specify the data type of the Java function return value.

    definition

    Specify "packageName.className. methodName" or "className.methodName" of the Java application.

    Do not specify the method arguments as they will be invalid.

    lang_name

    Specify "plextjavau".

    Example

    If the schema name is "javatest", the Java function name is "java_addOne", and the "packageName.className.methodName" of the Java application is "org.postgresql.plextjava.example.Parameters.addOne"

    db01=# CREATE FUNCTION javatest.java_addOne(INTEGER)
                       RETURNS INTEGER
                       AS 'org.postgresql.plextjava.example.Parameters.addOne'
                       LANGUAGE plextjavau;

    See

    • Refer to "Relationship between the Java Function Data Type and Application Data Type" in the Application Development Guide for information on data types.

    • Refer to "CREATE FUNCTION" under "Reference" in the PostgreSQL Documentation for details.

  3. Set privileges for users connecting to the database

    Grant privileges to users for database objects (such as tables, columns, and views) that will be accessed when accessing the database from the Java application. Use the GRANT statement to grant privileges.

    Example

    Grant privileges to user name "user01" to add data to table "table01"

    db01=# GRANT INSERT ON table01  to user01;
  4. Set privileges for Java functions

    Grant execution privileges for Java functions to users who call Java functions. Use the GRANT statement to grant privileges.

    Note

    Grant execution privileges for a Java function only to users who have permission to access the resources accessed by that functions, otherwise the users may inadvertently be granted improper access to those resources via the function.

    Example

    Grant privileges to user "user04" for the Java function "java_addOne"

    db01=# GRANT EXECUTE ON FUNCTION javatest.java_addOne(INTEGER) to user04;
  5. Disconnect from the database.

See

Refer to "Reference" in the PostgreSQL Documentation for information on the GRANT statement.

Storing Java applications

  1. Copy the Java application

    Manually copy the Java application in jar format to the directory below.

    domainRoot\plextjava\databaseName