Chapter 5. mod_tbPSM

Table of Contents

5.1. Overview
5.2. Installing Apache HTTP Server
5.3. Configuring mod_tbPSM
5.4. Creating and Executing a Procedure
5.4.1. Creating a Procedure
5.4.2. Executing a Procedure
5.5. Configuring Auto Login

This chapter describes how to use mod_tbPSM that calls tbPSM procedures and gets HTML pages using Apache HTTP web server.

5.1. Overview

To request HTTP pages via a web browser, Tibero provides an Apache module named mod_tbPSM that calls and transfers a procedure written with tbPSM.

When Apache HTTP server starts, it loads module libraries specified in the Apache configuration file. At this time, mod_tbPSM is also loaded from the Apache HTTP server.

The following are the steps for using the mod_tbPSM modules.

  1. Install Apache HTTP Server

  2. Register mod_tbPSM

  3. Write and execute a procedure

For more information about each step, refer to the corresponding sections.

5.2. Installing Apache HTTP Server

The version of Apache HTTP server optimized for mod_tbPSM is 2.2.31 (for UNIX) or 2.4.27 (for Windows).

For detailed information about Apache HTTP server, refer to the following address.

UNIX: https://httpd.apache.org/download.cgi#apache22
Windows 64bit: https://www.apachelounge.com/download
Windows 32bit: https://www.apachelounge.com/download

In UNIX systems, download and manually build the source code. In Windows systems, download the version of the binary that is appropriate for the version of VC installed in the system, and then install and execute it by referring to ReadMe.txt, which is included in the binary.

Note

If Tibero Windows 64-bit is used, Apache HTTP must be 64-bit.

5.3. Configuring mod_tbPSM

After Apache HTTP server is installed, modify Apache configuration file, $(Apache server installation path)/conf/httpd.conf, and then set up mod_tbPSM.

  • In UNIX

    Add the following in httpd.conf:

    LoadModule tbpsm_module       "${TB_HOME}/client/lib/libmod_tbpsm.so"
    <Location /tbpsm>
        SetHandler  tbpsm_handler
        AuthType Basic
        AuthName "Tibero"
    </Location>
  • In Windows

    Since Windows does not use the TB_HOME environment variable, specify an absolute path or copy the dll file to the module folder in the Apache installation path, and then add the following in httpd.conf:

    LoadModule tbpsm_module       modules/libmod_tbpsm.dll
    <Location /tbpsm>
        SetHandler  tbpsm_handler
        AuthType Basic
        AuthName "Tibero"
    </Location>

[Reference]

When specifying a path, use a back slash (\) for Windows and a slash (/) for Apache.

LoadModule tbpsm_module       c:/tibero/client/lib/libmod_tbpsm.dll
<Location /tbpsm>
    SetHandler  tbpsm_handler
    AuthType Basic
    AuthName "Tibero"
</Location>

Note

The Location section in the Apache configuration file should be identical to the previous example.

5.4. Creating and Executing a Procedure

This section describes how to create and execute a procedure that returns HTML pages using the HTP package.

Note

For more information about how to use of the HTP package described in this section, refer to "Chapter 23. HTP" in Tibero RDBMS tbPSM Reference Guide.

5.4.1. Creating a Procedure

Based on syntax of tbPSM, create HTML source code by calling a member procedure of the HTP package.

[Example 5.1] Example of a tbPSM Procedure Using HTP Package

CREATE OR REPLACE PROCEDURE hello (title in varchar2, text in varchar2)
AS
BEGIN
    HTP.HTMLOPEN;

    HTP.HEADOPEN;
    HTP.TITLE(title);
    HTP.HEADCLOSE;

    HTP.BODYOPEN;
    HTP.PRINT(text);
    HTP.BODYCLOSE;

    HTP.HTMLCLOSE;
END;
/

Description of the previous example is as follows:

  • In the HTML HEAD area, a string value of the title parameter is displayed in the web browser's title bar.

    For example, if 'abc' is passed to the hello procedure as the first argument, 'abc' is displayed in a title bar.

  • In the HTML BODY section, a string value of the text parameter is displayed in the web browser's main body of the screen.

    For example, if 'def' is passed to the hello procedure as the second argument, 'def' is displayed in the main body of the screen.

5.4.2. Executing a Procedure

The URL address format for executing a procedure using the mod_tbPSM module is:

http://{http_server_ip}:{http_server_port}/tbpsm/{tibero_dsn}/
{package_name}.{procedure_name}?{parameter1}={value1}&{parameter2}={value2)&...

ItemDescription
http_server_ipHTTP server's IP address.
http_server_portHTTP server's port number. If not set, the default value, 80, is used.
tbpsmLike the path specified in the httpd.conf file, it is a mandatory relative path for integration with mod_tbPSM
tibero_dsnDSN name specified in the tbdsn.tbr file. It indicates the Tibero DBMS where the procedure is stored.
package_nameIf a procedure to be called is a member of a package, the package name and a period (.) should be specified.
procedure_nameName of a procedure to be called.
parameter1, parameter2, ... , parameternParameter names of a procedure. In the URL address format, these items are query parameters.
value1. value2, ... , valuenProcedure's parameter values.

For example, to access an HTTP server whose address is "12.34.56.78" and call the hello procedure, in the previous example, located in Tibero DBMS server with a DSN named "test", the URL address is written as follows:

http://12.34.56.78/tbpsm/test/hello?title=abc&text=def

If the previous address is entered and requested in a web browser, a login screen will appear. The ID and password for the login screen are the same as for a Tibero DBMS account used to execute the hello procedure.

5.5. Configuring Auto Login

This section describes how to configure auto login for a URL address.

To request a web page from an HTTP server associated with mod_tbPSM, the server must be logged in with an account and its password. If auto login is configured, the server can be logged in automatically with the specified account and password. When using auto login, note that all users can access the specified URL address.

mod_tbPSM supports auto login by using the mod.tbr file in TB_HOME/client/config. The following is a sample file.

[Example 5.2] Sample mod.tbr

(LOCATION="/test")=(
    (USERNAME="tibero")
    (PASSWORD="tmax")
)

(LOCATION="/test2")=(
    (USERNAME="tibero")
    (PASSWORD="tmax")
)

(LOCATION="/test3")=(
    (USERNAME="sys")
    (PASSWORD="tibero")
)

To use multiple connection information as in the above sample, DSN connection information must be modified in the tbdsn.tbr file. The following is a sample file.

[Example 5.3] Sample tbdsn.tbr

test=(
    (INSTANCE=(HOST=localhost)
              (PORT=8629)
              (DB_NAME=tibero)
    )
)

test2=(
    (INSTANCE=(HOST=localhost)
              (PORT=8629)
              (DB_NAME=tibero)
    )
)

test3=(
    (INSTANCE=(HOST=localhost)
              (PORT=8629)
              (DB_NAME=tibero)
    )
)

The following briefly describes each item in mod.tbr.

ItemDescription
LOCATIONRelative URL address.
USERNAMEDatabase user account for login.
PASSWORDPassword of the database user account.

For example, when accessing 'http://12.34.56.78/tbpsm/test/hello?title=abc&text=def', a relative URL address is found based on 'http://12.34.56.78/tbpsm. If there is a LOCATION value in mod.tbr that matches the relative address, auto login is performed with the specified USERNAME and PASSWORD values.