Table of Contents
This chapter describes how to use mod_tbPSM that calls tbPSM procedures and gets HTML pages using Apache HTTP web server.
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.
Install Apache HTTP Server
Register mod_tbPSM
Write and execute a procedure
For more information about each step, refer to the corresponding sections.
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.
If Tibero Windows 64-bit is used, Apache HTTP must be 64-bit.
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>
The Location section in the Apache configuration file should be identical to the previous example.
This section describes how to create and execute a procedure that returns HTML pages using the HTP package.
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.
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.
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)&...
Item | Description |
---|---|
http_server_ip | HTTP server's IP address. |
http_server_port | HTTP server's port number. If not set, the default value, 80, is used. |
tbpsm | Like the path specified in the httpd.conf file, it is a mandatory relative path for integration with mod_tbPSM |
tibero_dsn | DSN name specified in the tbdsn.tbr file. It indicates the Tibero DBMS where the procedure is stored. |
package_name | If a procedure to be called is a member of a package, the package name and a period (.) should be specified. |
procedure_name | Name of a procedure to be called. |
parameter1, parameter2, ... , parametern | Parameter names of a procedure. In the URL address format, these items are query parameters. |
value1. value2, ... , valuen | Procedure'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.
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.
Item | Description |
---|---|
LOCATION | Relative URL address. |
USERNAME | Database user account for login. |
PASSWORD | Password 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.