Download as pdf or txt
Download as pdf or txt
You are on page 1of 92

Tibero

Application Developer's Guide

Tibero 5 SP1

Copyright 2014 TmaxData Co., Ltd. All Rights Reserved.


Copyright Notice

Copyright 2014 TmaxData Co., Ltd. All Rights Reserved.

5, Hwangsaeul-ro 329beon-gil, Bundang-gu, Seongnam-si, Gyeonggi-do, Korea

Restricted Rights Legend

All TmaxData Software (Tibero) and documents are protected by copyright laws and international convention.
TmaxData software and documents are made available under the terms of the TmaxData License Agreement
and may only be used or copied in accordance with the terms of this agreement. No part of this document may
be transmitted, copied, deployed, or reproduced in any form or by any means, electronic, mechanical, or optical,
without the prior written consent of TmaxData Co., Ltd.

Trademarks

Tibero is a registered trademark of TmaxData Co., Ltd. Other products, titles or services may be registered
trademarks of their respective companies.

Open Source Software Notice

This product includes open source software developed and/or licensed by "OpenSSL," "RSA Data Security, Inc.,"
"Apache Foundation," "Jean-loup Gailly and Mark Adler," and "Paul Hsieh's hash". Information about the
aforementioned and the related open source software can be found in the "${INSTALL_PATH}/license/oss_licenses"
directory.

Manual Information

Title: Tibero Application Developer's Guide

Publication Date: 2014-08-01

Product Number: Tibero 5 SP1

Edition: 2.1.1
Table of Contents
About This Document ................................................................................................................. ix

Chapter 1. Using Data Type ....................................................................................................... 1


1.1. Overview ..................................................................................................................... 1
1.1.1. String Type ........................................................................................................ 1
1.1.2. Number Type ..................................................................................................... 4
1.1.3. Datetime Type ................................................................................................... 4
1.1.4. Binary Type ....................................................................................................... 6
1.1.5. Embedded Type ................................................................................................. 7

Chapter 2. Using tbJDBC .......................................................................................................... 9


2.1. Installing JDK ............................................................................................................... 9
2.2. JDBC Standard Feature ................................................................................................ 9
2.2.1. JDBC 1.0 and JDBC 2.0 ................................................................................... 10
2.2.2. JDBC 3.0 ........................................................................................................ 12
2.2.3. JDBC 4.0 ........................................................................................................ 14
2.3. Basic Programming .................................................................................................... 16
2.3.1. Connection ...................................................................................................... 17
2.3.2. Execution ........................................................................................................ 18
2.3.3. Calling ............................................................................................................ 20
2.3.4. Commitment and Rollback ................................................................................ 21
2.3.5. Disconnection .................................................................................................. 21

Chapter 3. Using a Trigger ....................................................................................................... 23


3.1. Overview .................................................................................................................... 23
3.1.1. Trigger Components ......................................................................................... 23
3.1.2. Trigger Types ................................................................................................... 24
3.2. Creating a Trigger ....................................................................................................... 24

Chapter 4. Using XA ................................................................................................................ 27


4.1. Distributed Transaction ................................................................................................ 27
4.1.1. Two-phase Commit Mechanism ........................................................................ 27
4.1.2. In-doubt Transaction ......................................................................................... 29
4.2. XA API ....................................................................................................................... 30
4.2.1. XA Functions ................................................................................................... 30
4.2.2. Properties of the xa_open Function ................................................................... 31
4.2.3. XA Application Programming ............................................................................ 32
4.3. JDBC XA ................................................................................................................... 35
4.3.1. XA Interface .................................................................................................... 35
4.3.2. XA Interface Programming ................................................................................ 36
4.4. Integration of TP-Monitor and Tibero ............................................................................ 41
4.4.1. Integration of Tmax and Tibero ......................................................................... 41
4.4.2. Integration of Tuxedo and Tibero ....................................................................... 46

Tibero iii
Chapter 5. Using mod_tbPSM ................................................................................................. 55
5.1. Installing Apache HTTP Server .................................................................................... 55
5.2. Registering mod_tbPSM ............................................................................................. 55
5.3. Writing and Executing a Procedure .............................................................................. 56
5.3.1. Writing a Procedure ......................................................................................... 56
5.3.2. Executing a Procedure ..................................................................................... 57

Appendix A. tbJDBC Example ................................................................................................. 59


A.1. JdbcTest.class ........................................................................................................... 59

Appendix B. Example of Integrating Tibero with Tuxedo ......................................................... 63


B.1. tb_tux.env .................................................................................................................. 63
B.2. tb_tux.conf.m ............................................................................................................. 63
B.3. tmax32.fld .................................................................................................................. 64
B.4. trans_fml32.tbc .......................................................................................................... 65
B.5. builds.sh .................................................................................................................... 67
B.6. insert.c ...................................................................................................................... 67
B.7. select.c ...................................................................................................................... 69
B.8. buildc.sh .................................................................................................................... 71
B.9. create_table.sql .......................................................................................................... 71
B.10. run.sh ...................................................................................................................... 72

Index .......................................................................................................................................... 73

iv Tibero Application Developer's Guide


List of Figures
[Figure 4.1] A General Example of Two-phase Commit Mechanism .............................................. 28
[Figure 4.2] An Example of an In-doubt Transaction ..................................................................... 29

Tibero v
List of Examples
[Example 2.1] Basic Programming Using tbJDBC ........................................................................ 16
[Example 2.2] tbJDBC - Connection ........................................................................................... 56
[Example 2.3] tbJDBC - Execution ............................................................................................. 18
[Example 2.4] tbJDBC - Prepared Statements Declaration and Parameter Binding ........................ 19
[Example 2.5] tbJDBC - Calling .................................................................................................. 20
[Example 2.6] tbJDBC - Disconnection ....................................................................................... 22
[Example 3.1] Creating a Trigger ................................................................................................ 25
[Example 5.1] Example of a tbPSM Procedure Using HTP package ............................................. 56

Tibero vii
About This Document

Intended Audience
This document is intended for developers who want to develop applications using various application

libraries provided by Tibero (hereafter Tibero).

Required Knowledge
The user must have knowledge of the following in order to understand this guide:

Databases

RDBMS

Java programming

tbPSM language and package usage

Document Scope
This guide does not contain all the information required to operate Tibero . For information related to
installation, configuration, operation and management, refer to each relevant guide.

Note

For more information about Tibero installation and configuration, refer to the "Tibero Installation
Guide."

About This Document ix


Document Organization
This guide consists of five chapters and two appendixes.

Descriptions for each section are as follows:

Chapter 1: Using Data Type

Describes the data types provided by Tibero and explains their usage.

Chapter 2: Using tbJDBC

Describes how to use tbJDBC.

Chapter 3: Using a Trigger

Describes how to use a trigger.

Chapter 4: Using XA

Describes how to use XA (Extended Architecture) needed to handle distributed transactions.

Chapter 5: Using mod_tbPSM

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

Appendix A: tbJDBC Example

Provides the full source code of an example program written using tbJDBC.

Appendix B: Example of Integrating Tibero with Tuxedo

Provides the full source code of an example program that integrates Tibero with Tuxedo and relevant
scripts.

x Tibero Application Developer's Guide


Conventions
Convention Meaning

<AaBbCc123> Filename of a program or source code

<Ctrl>+C Hold the Control key and press C

[Button] Button or Menu name

Boldface Emphasis

" " (double quotes) Reference to chapters or sections in the manual, or to other related
documentations

'Input Item' Description of an input item on the screen

Hyperlink E-mail account, website, or a link to other chapters or sections

> Hierarchical order of menus

+---- Files or directories exist below.

|---- Files or directories do not exist below.

Reference or note
Note

[Figure 1.1] Figure name

[Table 1.1] Table name

AaBbCc123 Command, execution result, or example code

{} Required argument

[] Optional argument

| Selective argument

About This Document xi


System Requirements
Requirements

Supported Platforms HP-UX 11i (PA-RISC, ia64)

Solaris (SPARC 9/Solaris 9)

AIX (PPC 5L/AIX 5.3)

GNU (X86, 64, IA64)

Linux Kernel 2.6 or later

Windows (x86) 32bit/64bit

Hardware At least 1.5 GB hard disk space

More than 512 MB RAM

Compiler PSM (C99 support needed)

tbESQL/C (C99 support needed)

xii Tibero Application Developer's Guide


Related Documents
Document Description

Tibero Describes system requirements and specific methods for installation and
uninstallation.
Installation Guide

Tibero Describes the tbCLI (Call Level Interface) concept, components and
program structure, as well as data types, functions, and error messages
tbCLI Guide
needed to write tbCLI applications.

Tibero Describes how to create and use external procedures and methods.

External Procedure Guide

Tibero Describes methods to develop applications using JDBC functions provided


by Tibero .
JDBC Developer's Guide

Tibero Describes methods to write a variety of database applications that use


the C programming language to work on databases.
tbESQL/C Guide

Tibero Describes methods to write a variety of database applications that use


the COBOL programming language to work on databases.
tbESQL/COBOL Guide

Tibero Describes tbPSM's (Procedure Storage Module) concept, syntax, and


components, with control structures, composite types, subprograms,
tbPSM Guide
packages, SQL execution methods, and error handling, which are
necessary for writing tbPSM programs.

Tibero Describes the details of tbPSM packages, such as prototypes, parameters,


and examples of each procedure and function included in those packages.
tbPSM Reference Guide

Tibero Describes what a DBA should know to logically and physically manage
Tibero , and introduces a variety of tools to support management activities.
Administrator's Guide

Tibero Describes tbAdmin, a GUI-based tool which provides SQL/PSM


processing and system management functions for DBAs, along with the
tbAdmin Guide
installation and operation methods.

Tibero Describes the installation, configuration, and operation methods of the


database-handling utilities.
Utility Guide

Tibero Describes troubleshooting methods for all sorts of errors that may occur
while using Tibero .

About This Document xiii


Document Description

Error Reference Guide

Tibero Describes the initialization parameters, data dictionary, static views and
dynamic views used by Tibero .
Reference Guide

Tibero Describes SQL statements needed to work with databases and write
applications.
SQL Reference Guide

xiv Tibero Application Developer's Guide


Contact Information

Korea
TmaxData Co., Ltd.
5, Hwangsaeul-ro 329beon-gil, Bundang-gu,
Seongnam-si, Gyeonggi-do, 463-824
South Korea
Tel: +82-31-779-7113
Fax: +82-31-779-7119
Email: tibero@tmaxdata.com
Web (Korean): http://www.tmaxdata.com
Technical Support: http://technet.tmaxsoft.com

USA
TmaxSoft, Inc.
560 Sylvan Avenue Englewood Cliffs, NJ 07632
U.S.A
Tel: +1-201-567-8266
Fax: +1-201-567-7339
Email: info@tmaxsoft.com
Web (English): http://www.tmaxsoft.com

Japan
TmaxSoft Japan Co., Ltd.
5F Sanko Bldg, 3-12-16 Mita, Minato-Ku, Tokyo, 108-0073
Japan
Tel: +81-3-5765-2550
Fax: +81-3-5765-2567
Email: info@tmaxsoft.co.jp
Web (Japanese): http://www.tmaxsoft.co.jp

About This Document xv


China
TmaxSoft China Co., Ltd.
Beijing Silver Tower, RM 1508, 2# North Rd Dong San Huan,
Chaoyang District, Beijing, China, 100027
China
Tel: +86-10-6410-6145~8
Fax: +86-10-6410-6144
Email: info.cn@tmaxsoft.com
Web (Chinese): http://www.tmaxsoft.com.cn

Brazil
TmaxSoft Brazil
Avenida Copacabana, 177 - 3 andar 18 do Forte Empresarial,
Alphaville - Barueri, Sao Paulo, SP-Brasil CEP 06472-001
Brazil
Tel: +86-10-6410-6145~8
Fax: +86-10-6410-6144
Email: contato.brasil@tmaxsoft.com

Russia
Tmax Russia L.L.C.
Grand Setun Plaza, No A204 Gorbunova st.2,
Moscow, 121596
Russia
Tel: +7(495)970-01-35
Email: info.rus@tmaxsoft.com
Web (Russian): http://ru.tmaxsoft.com

xvi Tibero Application Developer's Guide


Singapore
Tmax Singapore Pte. Ltd.
430 Lorong 6, Toa Payoh 10-02,
OrangeTee Building, 319402
Singapore
Tel: +65-6259-7223
Email: info.sg@tmaxsoft.com
Web (English): http://www.tmaxsoft.com

United Kingdom
TmaxSoft UK Ltd.
Surrey House, Suite 221, 34 Eden Street,
Kingston-Upon-Thames, KT1 1ER
United Kingdom
Tel: + 44-(0)20-8481-3776
Email: info.uk@tmaxsoft.com
Web (English): http://www.tmaxsoft.com

About This Document xvii


Chapter 1. Using Data Type

This chapter introduces the default data types provided in Tibero and describes their usage.

1.1. Overview
Data type is used when a schema object is created for a database. General client programs can use
variables that corresponds to all data types.

Data types provided in Tibero are:

Classification Data Type Description

String type CHAR, VARCHAR, VARCHAR2, Strings.


NCHAR, NVARCHAR, CLOB,
NCLOB, LONG, SQLXML

Number type NUMBER Integers or real numbers.

Datetime type DATE, TIME, TIMESTAMP, Times and/or dates.

TIMESTAMP WITH TIME ZONE,

TIMESTAMP WI TH LOCAL TIME


ZONE,

INTERVAL YEAR TO MONTH,

INTERVAL DAY TO SECOND

Binary type RAW, BLOB, LONG RAW Large amounts of binary data.

Embedded type ROWID A column type that Tibero automatically


inserts in every row before being declared.

Note

For more information about data types, refer to the "Tibero SQL Reference Guide."

1.1.1. String Type


The following descriptions explain how to use the String data type.

Chapter 1. Using Data Type 1


CHAR
The CHAR type stores fixed-length character strings.

Used in the following way:

CHAR[(size)]

Option Description

size The size option can be set. (Maximum: 2,000 bytes)

- If set, the data length is the byte length of the data.

- If not set, the data length will be 1 byte by default.

VARCHAR
The VARCHAR type stores variable-length character strings.

Used in the following way:

VARCHAR(size)

Option Description

size The data length is the byte length of the data. (Maximum: 4,000 bytes)

VARCHAR2
The VARCHAR2 type stores variable-length character strings. It is displayed as VARCHAR when a table
is created.

Used in the following way:

VARCHAR2(size)

Option Description

size The data length is the byte length of the data. (Maximum: 4,000 bytes)

NCHAR
The NCHAR type stores fixed-length character strings that use the national character set.

Used in the following way:

2 Tibero Application Developer's Guide


NCHAR(size)

Option Description

size The data length is the byte length of the data. (Maximum: 2,000 bytes)

NVARCHAR
The NVARCHAR type stores variable-length character strings that use the national character set. It is
displayed as NVARCHAR when a table is created.

Used in the following way:

NVARCHAR(size)

Option Description

size The data length is the byte length of the data. (Maximum: 4,000 bytes)

CLOB
The CLOB type stores a large amount of readable strings.

Used in the following way:

CLOB

The maximum data size is 4GB.

NCLOB
The NCLOB type stores a large amount of readable strings that use the national character set.

Used in the following way:

NCLOB

The maximum data size is 4GB.

LONG
The LONG type stores a large amount of strings. This type is supported only for compatibility with Oracle.
The CLOB type is recommended for all other purposes.

Used in the following way:

Chapter 1. Using Data Type 3


LONG

1.1.2. Number Type

NUMBER
The NUMBER type stores variable-length integers or real numbers.

Used in the following way:

NUMBER[(precision | precision , scale)]

Option Description

precision Sets the total number of digits.

scale Sets the number of digits to the right of the decimal point.

1.1.3. Datetime Type

DATE
The DATE type stores fixed-length strings of year, month, and date.

Used in the following way:

DATE

TIME
The TIME type stores fixed-length strings of hour, minute, and second.

Used in the following way:

TIME

TIMESTAMP
The TIMESTAMP type is an expanded type of the DATE type. This type stores a fixed-length string of
year, month, date, and time.

Used in the following way:

TIMESTAMP[(frac_sec_prec)]

4 Tibero Application Developer's Guide


Option Description

frac_sec_prec Sets the fractional seconds precision.

A number between 0 and 9 can be used. (Default: 9)

TIMESTAMP WITH TIME ZONE


The TIMESTAMP WITH TIME ZONE type is an expanded type of the TIMESTAMP type.This type converts
a given time to UTC (Coordinated Universal Time) time format, and stores a fixed-length string made of
year, month, date, and time.

Used in the following way:

TIMESTAMP[(frac_sec_prec)] WITH TIME ZONE

Option Description

frac_sec_prec Sets the fractional seconds precision.

A number between 0 and 9 can be used. (Default: 9)

TIMESTAMP WITH LOCAL TIME ZONE


The TIMESTAMP WITH LOCAL TIME ZONE type converts a given time to a time in UTC time like
TIMESTAMP WITH TIME ZONE, and stores a fixed-length string made of year, month, and date. This
type has the same length as TIMESTAMP.

Used in the following way:

TIMESTAMP[(frac_sec_prec)] WITH LOCAL TIME ZONE

Option Description

frac_sec_prec Sets the fractional seconds precision.

A number between 0 and 9 can be used. (Default: 9)

INTERVAL YEAR TO MONTH


The INTERVAL YEAR TO MONTH type stores a fixed-length time interval of year and month.

Used in the following way:

Chapter 1. Using Data Type 5


INTERVAL YEAR [(year_prec)] TO MONTH

Option Description

year_prec Sets the year precision.

A number between 0 and 9 can be used. (Default: 2)

Limits the number of digits of an interval year.

INTERVAL DAY TO SECOND


The INTERVAL DAY TO SECOND type stores a fixed-length time interval of day and time.

Used in the following way:

INTERVAL DAY [(day_prec)] TO SECOND [(frac_sec_prec)]

Option Description

day_prec Sets the day precision.

A number between 0 and 9 can be used. (Default: 2)

frac_sec_prec Same as the frac_sec_prec option of the TIMESTAMP type.

Note

This type can limit the number of digits stored for date and fractional second using day_prec and
frac_sec_prec.

1.1.4. Binary Type

RAW
The RAW type stores variable-length binary data.

Used in the following way:

RAW(size)

Option Description

size The data length is the byte length of the data. (Maximum: 2,000 bytes)

6 Tibero Application Developer's Guide


BLOB
The BLOB type stores a large amount of binary data.

Used in the following way:

BLOB

The maximum data size is 4GB.

LONG RAW
The LONG RAW type stores a large amount of binary data. This type is supported only for compatibility
with Oracle. The BLOB type is recommended for all other purposes.

Used in the following way:

LONG RAW

1.1.5. Embedded Type


The ROWID type stores fixed-length row addresses of a database table.

Used in the following way:

ROWID

Chapter 1. Using Data Type 7


Chapter 2. Using tbJDBC

Tibero provides the tbJDBC (Tibero Java database connectivity) interface to enable Java programs to
run SQL statements and access the database.

tbJDBC operates in JDK 1.4 (or later version) environment. To fully use all the functions of JDBC 4.0,
JDK 6 or later needs to be used. When JDK 6 or later is used, the driver file is provided as tibero5-jdbc.jar
and for JDK 1.4 as tibero5-jdbc-14.jar.

Note

This guide briefly explains JDBC programming. For more information about tbJDBC, refer to the
"Tibero JDBC Developer's Guide."

2.1. Installing JDK


To use tbJDBC, JDK 1.4 or later must be installed.

JDK can be downloaded from the following website:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

If Oracle's JDK cannot be used, install the appropriate JDK. For example, the JDK for HP-UX and AIX
can be downloaded from HP and IBM website respectively.

Instructions for installing JDK for each operating system can be found here:

http://www.oracle.com/technetwork/java/index.html

Note

For vendor-specific JDK installation instructions, refer to each vendor's documentation.

2.2. JDBC Standard Feature


tbJDBC complies with the JDBC 4.0 standard that includes the following JDBC standards. The standard
specifies mandatory features and optional features that need to be implemented by each vendor.Therefore,
some optional features may not be supported.

JDBC 3.0 API

Chapter 2. Using tbJDBC 9


JDBC 2.0 API (JDBC 2.0 Optional Package API and JDBC 2.1 core API)

JDBC 1.2 API

JDBC 1.0 API

This section describes the standard features of tbJDBC according to JDBC version. For more information,
refer to Sun Microsystems's JDBC 4.0 Specification.

2.2.1. JDBC 1.0 and JDBC 2.0


The following describes the supported and unsupported features of tbJDBC for JDBC 1.0 and JDBC 2.0
:

Supported Features
SQL-99 data types

Of the newly added data types in SQL-99, tbJDBC supports only BLOB and CLOB. When using the
BLOB and CLOB data types in Tibero, the following rules apply:

BLOB and CLOB interfaces are available while a related transaction is being processed.

BLOB and CLOB interfaces are implemented through a locator.

The locator is a logical pointer to data that exists in a database server.

Interface methods

Supported interface methods are:

java.sql.Array

java.sql.Blob

java.sql.CallableStatement

java.sql.Clob

java.sql.Connection

java.sql.DatabaseMetaData

java.sql.Driver

10 Tibero Application Developer's Guide


java.sql.PreparedStatement

java.sql.ResultSet

java.sql.ResultSetMetaData

java.sql.Statement

java.sql.Struct

Driver that implements static initialization

The Driver class that implements the java.sql.Driver interface method can register a newly created
driver instance with a driver manager by calling the Drivermanager.registerDriver method in a static
initialization block.

Extended feature of SQL-92 entry level

DROP TABLE and ESCAPE statements can be used.

Scalar functions

All scalar functions supported in a database server can be used. Scalar functions can be searched with
the DatabaseMetaData class.

Multithreading

Multiple threads can simultaneously process all operations for objects that exist in the java.sql and
javax.sql packages.

Scrollable ResultSet

A ResultSet can be searched backwards and forwards. A ResultSet supports relative and absolute
positioning.

Updatable ResultSet

A ResultSet can be updated.

Positioned updates and deletions

A record in the current position set by a cursor in a ResultSet can be updated and deleted.

Sensitive ResultSet

Data generated after a ResultSet cursor is opened can be committed.

Chapter 2. Using tbJDBC 11


Batch updates

Multiple updates can be processed at the same time.

RowSet feature

Data can be easily transferred and handled.

Distributed transactions

Enables transactions to be distributed to multiple database servers.

Unsupported Features
SQL-99 data types

Of the SQL-99 data types, tbJDBC does not support Array, Ref, or Struct.

Interface methods

Unsupported interface methods are:

java.sql.Ref

java.sql.SQLData

java.sql.SQLInput

java.sql.SQLOutput

Exception for a truncated data

If data is unexpectedly truncated by the JDBC driver, the invocation of the Data Truncation warning
for reading processes and the Data Truncation exception for writing processes are not supported.

2.2.2. JDBC 3.0


The following describes the JDBC 3.0 standard features. JDBC 3.0 API can be used in the J2SE platform
and version 1.4 or later environment.

Supported Features
Interface

Supported interfaces are:

12 Tibero Application Developer's Guide


java.sql.ParameterMetaData

java.sql.Savepoints

javax.sql.ConnectionEventListener

javax.sql.ConnectionPoolDataSource

javax.sql.DataSource

javax.sql.PooledConnection

javax.sql.RowSet

javax.sql.RowSetInternal

javax.sql.RowSetListener

javax.sql.RowSetMetaData

javax.sql.RowSetReader

javax.sql.RowSetWriter

javax.sql.XAConnection

javax.sql.XADataSource

Connection pooling configuration

Supports the API for setting various parameters, used for connection pooling, such as the maximum
pool size, the minimum pool size, and the initial pool size.

Statement pooling

Supports statement pooling related to connection pooling.

ParameterMetaData

The JDBC class implementing the ParameterMetaData interface provides the number of parameters
used in prepared statements. However, it does not provide metadata describing data type or property.

Savepoint

Chapter 2. Using tbJDBC 13


By implementing the Savepoint interface, the savepoint's setting, commitment, and rollback features
are provided. However, the Connection.releaseSavepoint java.sql method, that releases the savepoint,
is not supported.

Automatically generated key

By using the getGeneratedKeys function of a ResultSet of a SQL statement, the key or an


automatically generated column value of the result row can be obtained.

ResultSet Holdability

Whether to maintain or close a ResultSet, when a commitment occurs while a ResultSet is opened,
can be set. tbJDBC only supports maintaining a ResultSet.

Returning Multiple ResultSets

The opening of multiple ResultSets by a single SQL statement is supported.

Modifying data in BLOB and CLOB object

Data modification included in BLOB and CLOB objects is supported with an updateXXX API.

Unsupported Features
Added data types

Type Description

java.sql.Types.DATALINK The ability to access external resources, such as URLs, is not supported.

java.sql.Types.BOOLEAN This data type, which is logically identical to the bit type, is not supported.

Searching and modifying an object referred by a REF object

The searching and modifying of an object referred by a REF object are not supported.

Mapping data types

User defined data types (UDTs) and java classes can be mapped with the JDBC API. However, Tibero
does not support UDT.

2.2.3. JDBC 4.0


The following describes the standard features of JDBC 4.0. JDBC 4.0 API can be used in the Java SE
platform and version 6 or later environment.

14 Tibero Application Developer's Guide


Supported Features
Interface

Supported interfaces are:

java.sql.NClob

java.sql.RowId

java.sql.SQLXML

java.sql.Wrapper

javax.sql.StatementEventListener

XML data types added in SQL:2003

XML data types are supported with the SQLXML interface.

Auto java.sql.Driver discovery

The usage of a driver object, without loading the java.sql.Driver class by using Class.forName method,
is supported.

National character set

The API for supporting national character set, specified separately by each database, has been added.

Improved SQLException

Consecutively chained exceptions can be invoked to output a more detailed information. In addition,
new exception types have been added.

Improved BLOB/CLOB feature

The API for creating and releasing a BLOB or CLOB object is supported.

SQL ROWID data type

The usage of the SQL ROWID type using the rowid interface is supported.

Accessing an actual JDBC object

Accessing an actual JDBC object with the wrapper interface is supported in an application server or in
the connection pooling environment.

Chapter 2. Using tbJDBC 15


Notifying the actual connection status in the connection pooling environment

When a connection is closed or not available anymore in the connection pooling environment, the status
is notified to the objects of pooled statements.

Unsupported Features
Searching a user defined type and hierarchical structure

The usage of the API for searching for a user defined type's property and hierarchical structure is not
supported.

2.3. Basic Programming


This section describes how to write a basic java program using interface methods provided in tbJDBC.

Note

To see the complete source code of the basic program explained in this section, refer to
Appendix A. tbJDBC Example.

The following is a section of the JdbcTest file that includes the public class:

[Example 2.1] Basic Programming Using tbJDBC

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;

public class JdbcTest


{
Connection conn;

public static void main(String[] args) throws Exception


{
JdbcTest test = new JdbcTest();

test.connect(); ... <A> ...


test.executeStatement(); ... <B> ...

16 Tibero Application Developer's Guide


test.executePreparedStatement(); ... <C> ...
test.executeCallableStatement(); ... <D> ...
test.disconnect(); ... <E> ...
}

/* ... Implementation of memeber functions by feature */


}

The line of code labeled <A> connects to the database through the JdbcTest class.

The lines of code labeled <B> through <D> execute several member functions.

The line of code labeled <E> releases the connection to the database.

The following describes the implementation of the member functions (called by lines labeled <A> through
<E> in the previous example).

2.3.1. Connection
The connect member function (labeled <A> in [Example 2.1]) connects to the database using the default
driver manager. To use this member function, the java.sql.DriverManager class must be declared.

[Example 2.2] tbJDBC - Connection

private void connect() throws SQLException, ClassNotFoundException


{
Class.forName("com.tmax.tibero.jdbc.TbDriver");

conn = DriverManager.getConnection(
"jdbc:tibero:thin:@localhost:8629:tibero",
"tibero", "tmax");

if (conn == null)
{
System.out.println("connection failure!");
System.exit(-1);
}
System.out.println("Connection success!");
}

Description of the previous example is as follows:

1. The Class.forName method is called.

The com.tmax.tibero.jdbc.TbDriver class is loaded, which registers the default driver that will be used
by the user.

Chapter 2. Using tbJDBC 17


2. The DriverManager.getConnection method is called.

Connection to the database is requested through the registered driver.

URL of the database that will be connected using the parameters of the DriverManager.getConnection
method must be entered by the user. The DriverManager class checks whether the connection to the
database is possible with the given parameters.

3. Database connection for the conn object using the getConnection method is created.

To release the connection, the close member function is used (not shown above).

2.3.2. Execution
tbJDBC uses the concept of statements similar to those used in clients of other databases.

The executeStatement member function (labeled <B> in [Example 2.1]) executes statements.

[Example 2.3] tbJDBC - Execution

private void executeStatement() throws SQLException


{
String dropTable = "drop table emp";
String createTable = "create table emp (id number, "+
" name varchar(20), salary number)";
String InsertTable = "insert into emp values(1000, 'Park', 5000)";

Statement stmt = conn.createStatement();

try {
stmt.executeUpdate(dropTable);
} catch(SQLException e) {
// if there is not the table
}

stmt.executeUpdate(createTable);
stmt.executeUpdate(InsertTable);

stmt.close();
}

Description of the previous example is as follows:

1. dropTable, createTable, and InsertTable are converted to string object reference variables.

SQL statements that will be executed are created in these object reference variables.

18 Tibero Application Developer's Guide


2. A new statement is created, using the createStatement method of the conn object.

3. A particular command is executed, using the executeUpdate(str) method.

After creating the statement, a desired task can also be executed by binding a parameter.

The executePreparedStatement member function (labeled <C> in [Example 2.1]) executes a query
to which the parameter is bound to.

[Example 2.4] tbJDBC - Prepared Statements Declaration and Parameter Binding

private void executePreparedStatement() throws SQLException


{
PreparedStatement pstmt = conn
.prepareStatement("select name from emp where id = ?"); ... <1> ...

pstmt.setString(1, "1000");

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {
System.out.println(rs.getString(1));
}

pstmt.close();
}

Description of the previous example is as follows:

1. A prepared statement with the PreparedStatement class is declared.

2. A PreparedStatement is created using the prepareStatement method of the conn object. The
prepared statement can obtain results using the executeUpdate and executeQuery functions.

3. The order and the values of the parameters to be bound are set using the setString(bind_no,
bind_value) method.

pstmt.setString(1, "1000") binds "1000" to the first parameter of the prepared statement (labeled
<1> in [Example 2.4]).

4. After the parameter is bound, ResultSet can be obtained by executing the executeQuery method.

ResultSet is conceptually the same as obtaining a cursor for tbCLI or tbESQL. Execution results can
be checked in string format by using the getString(result_no) method.

Chapter 2. Using tbJDBC 19


2.3.3. Calling
In a program written with tbJDBC, PL/SQL statements can be called. These statements are called Callable
statement.

The executeCallableStatement member function (labeled <D> in [Example 2.1]) executes callable
statements.

[Example 2.5] tbJDBC - Calling

private void executeCallableStatement() throws SQLException


{
String callSQL =
" CREATE PROCEDURE testProc "+
" (ID_VAL IN NUMBER, SAL_VAL IN OUT NUMBER) as " +
" BEGIN" +
" update emp" +
" set salary = SAL_VAL" +
" where id = ID_VAL;" +
" select salary into SAL_VAL" +
" from emp" +
" where id = ID_VAl;" +
" END;";
String dropProc = "DROP PROCEDURE testProc";

Statement stmt = conn.createStatement();

try {
stmt.executeUpdate(dropProc);
} catch(SQLException e) {
// if there is not the procedure
}

stmt.executeUpdate(callSQL);

CallableStatement cstmt = conn.prepareCall("{call testProc(?, ?)}");


cstmt.setInt(1, 1000);
cstmt.setInt(2, 7000);
cstmt.registerOutParameter(2, Types.INTEGER);
cstmt.executeUpdate();

int salary = cstmt.getInt(2);


System.out.println(salary);

stmt.close();
cstmt.close();
}

20 Tibero Application Developer's Guide


Description of the previous example is as follows:

1. A procedure using the CREATE PROCEDURE statement is created.

Data definition language (DDL) statements are executed by using the executeUpdate(query_str)
method like any other statements.

2. Callable statements are created by using the prepareCall(str) method of the conn object through
the CallableStatement class.

The created callable statements bind parameters like other prepared statements.

To bind parameters, use binding methods such as setInt(bind_no, bind_value). For example,
after using the setInt method, call the executeUpdate method.

3. An output parameter of the parameters bound by using the registerOutParameter(bind_no,


type) method of the CallableStatement class is registered.

The output parameter to be registered is the second parameter (SAL_VAL IN OUT NUMBER) of the
procedure created in the first step. This parameter can be registered as an output parameter, because
it is declared as an input and an output parameter.

4. After executing the statement by calling the executeUpdate method, an execution result is obtained
by using an appropriate method for the output parameter. The output parameter is an integer type and
displays the result in the variable called "salary" using the getInt(bind_no) method of the
CallableStatement class.

2.3.4. Commitment and Rollback


A transaction consists of one or more SQL statements. When SQL statements are executed, all SQL
statements are committed or rolled back.

tbJDBCcan set a transaction-related value in a connection object. The default mode is auto-commit.

To change a transaction handling mode, add the following lines of source code:

conn.setAutoCommit(false);
conn.rollback();
conn.commit();
conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITED)

2.3.5. Disconnection
The disconnect member function (labeled <E> in [Example 2.1]) releases a connection to database.

Chapter 2. Using tbJDBC 21


[Example 2.6] tbJDBC - Disconnection

private void disconnect() throws SQLException


{
if (conn != null)
conn.close();
}

If the conn object exists, connections to the database can be released using the close member function.

22 Tibero Application Developer's Guide


Chapter 3. Using a Trigger

This chapter explains the basic concept of a trigger and how to create it.

3.1. Overview
Trigger is a kind of schema object. A trigger is automatically executed when a condition, predefined by
a database, is met or a certain action is performed. For example, a trigger will be executed when a
particular event occurs in a database or when a DDL statement, configured by a user, is executed.

Contents of a trigger consist of persistent stored modules(PSMs). A trigger can be created by calling a
predefined PSM object or by declaring it in an anonymous block.

3.1.1. Trigger Components


The three components of a trigger are:

Conditional statements or events for executing a trigger

Execution condition constraints

Actions to be performed

The following is an example of creating a trigger named alarm_for_balance:

CREATE OR REPLACE TRIGGER alarm_for_balance


BEFORE INSERT OR UPDATE ON balance_tab ... <A> ...
FOR EACH ROW
WHEN (new.balance < 3000) ... <B> ...
CALL alarm_for_balance_fn() ... <C> ...

As shown in <A> of the previous example, when a row is inserted or updated in the balance column of
the balance_tab table, the line of code labeled <B> is executed.

The line of code labeled <B> checks if the row value is less than 3000.

If the above condition is met, the function, alarm_for_balance_fn, is called, as shown in <C>.
Actions defined in the function will be executed.

Chapter 3. Using a Trigger 23


3.1.2. Trigger Types
Trigger types are divided as follows:

Row and Statement

Type Description

Row A trigger is executed for every row in which INSERT, UPDATE, or DELETE occurs.

Whenever an operation occurs in a row, the trigger is executed just before or after
the operation.

Statement A trigger is executed only one time per statement regardless of the number of
rows.

BEFORE and AFTER

Type Description

BEFORE A trigger is executed before a conditional statement is executed.

AFTER A trigger is executed after a conditional statement is executed.

A trigger type can be one of the following: BEFORE row, BEFORE statement, AFTER row, and AFTER
statement.

3.2. Creating a Trigger


A trigger can be created as follows:

CREATE [OR REPLACE] TRIGGER trigger_name


{BEFORE | AFTER} {INSERT | UPDATE | DELETE} ON table_name
[FOR EACH ROW]
WHEN (condition_constraint)
{[Declaration]
BEGIN
...
END;} |
CALL function_or_procedure_name

Note

For more information about the syntax of a trigger, refer to the "Tibero SQL Reference Guide."

The following is an example of a row type trigger. A log is recorded whenever the value of a row in the
COUNT column of the Deck_tbl table is greater than 1000.

24 Tibero Application Developer's Guide


[Example 3.1] Creating a Trigger

CREATE OR REPLACE TRIGGER Log_overflow


AFTER UPDATE ON Deck_tbl
FOR EACH ROW
WHEN (new.count > 1000)
BEGIN
INSERT
INTO Deck_log (Deck_id, Timestamp, New_count, Action)
VALUES (:new.Deck_no, SYSTIMESTAMP, :new.count, 'overflow');
END;

In Tibero, the CREATE statement recognizes the block enclosed by BEGIN and END as PSM. If this
statement is compiled, a PSM schema object is created and saved in the database. When an error occurs
during the compilation, the error can be checked statically.

Chapter 3. Using a Trigger 25


Chapter 4. Using XA

This chapter explains XA (Extended Architecture) used for handling distributed transactions.

4.1. Distributed Transaction


Several SQL statements bound in a single transaction are committed or rolled back together in a single
database instance.

There could be several SQL statements bound in a single transaction, in which several database instances
are created from several databases that are connected over a network. These SQL statements should
be committed or rolled back together.

A transaction, in which several nodes or databases participate in, is called a distributed transaction.

Note

For more information about distributed transactions, refer to the "Tibero Administrator's Guide."

4.1.1. Two-phase Commit Mechanism


Tibero supports X/Open DTP (Distributed Transaction Processing) XA. XA handles distributed transactions
using the two-phase commit protocol.

To ensure the integrity of a transaction in a distributed environment, the two-phase commit protocol is
used.

When more than one node participates a single transaction, the node that receives a request from the
user and starts the transaction first is the coordinator. In a system in which TP-Monitor exists, the
TP-Monitor is the coordinator.

Chapter 4. Using XA 27
The following figure shows a general example of the two-phase commit mechanism:

[Figure 4.1] A General Example of Two-phase Commit Mechanism

The two-phase commit mechanism is performed in two phases. The figure above is described as follows:

1. First Phase (or prepare phase)

In this phase, commitment is prepared.

Detailed processes of the first phase:

Step Description

send "prepare" Each node receives a message from a coordinator node, requesting to prepare
commitment.

reply "prepared" Each node checks whether a commitment is possible. If commitment is not
possible, it rolls back independently. If commitment is possible, each node sends
a message to the coordinator node indicating that commitment has been prepared.

2. Second Phase (or commit phase)

In this phase, commitment is performed.

Detailed processes of the second phase:

Step Description

send "commit" The coordinator node receives messages, that commitment has been prepared,
from all nodes. After checking these messages, the coordinator node sends
messages requesting to commit.

reply "committed" Each node records logs of commitment, and then sends a message to the
coordinator node indicating that commitment has been completed.

28 Tibero Application Developer's Guide


4.1.2. In-doubt Transaction
When a database receives the first message of the two-phase commit mechanism, it prepares commitment
by locking necessary resources for distributed transactions or by logging them. However, the database
may not receive the second message (commitment or rollback) in the process of completing the preparation
due to network problems.

In this case, the database cannot decide whether to commit or rollback the transaction and just waits until
the next message is delivered, while holding the lock on the prepared resources. This type of transaction,
that is prepared but holds resources without receiving the next message, is called an In-doubt transaction.

For example, an in-doubt transaction occurs when a server of a certain node goes down, a coordinator
node's message is not delivered to a node due to a network problem, or a coordinator node does not
receive a reply from a node although the coordinator node sends a message requesting preparation.

In this case, because the coordinator node does not receive a reply from a node even though it receives
replies from all the other nodes, it marks the transaction as an in-doubt transaction and sends a message
to all the other nodes requesting a rollback.

The following figure shows an example of an in-doubt transaction:

[Figure 4.2] An Example of an In-doubt Transaction

Although all nodes receive messages that commitment is prepared and send replies, if a node does not
receive a message requesting commitment in the second phase, the transaction is an in-doubt transaction.
If a coordinator node does not receive a reply that commitment is completed from a node, although the
node completes requested commitment properly, the transaction is also an in-doubt transaction.

To resolve a transaction that is pending with locked resources, a coordinator node needs to rollback
transactions of all the nodes, or a database administrator needs to extract the in-doubt transaction and
handle it manually.

Chapter 4. Using XA 29
Data from VT_XA_BRANCH and DPV_2PC_PENDING can be used to extract an in-doubt transaction.

Note

VT_XA_BRANCH is a table that displays information about all XA transaction branches that operate
in the current database server in real time. DPV_2PC_PENDING is a view that displays information
of pending XA transaction branches.

For more information, refer to the "Tibero RDBMS Reference Guide" and "Tibero RDBMS
Administrator's Guide."

4.2. XA API
To handle distributed transactions using TP-Monitor, an XA API must be used.

Tibero enables the development of an XA application program that meets standards by supporting X/Open
DTP XA.

4.2.1. XA Functions
Tibero provides XA functions, but they can only be used by C programming language.

The following table lists XA functions:

Function Description

xa_open Connects to a resource manager.

xa_close Disconnects from a resource manager.

xa_start Starts a new transaction with a given global transaction identifier (XID) or
associates current process with an existing transaction.

xa_end Disassociates current process from a given XID.

xa_rollback Rolls back a transaction associated with a given XID.

xa_prepare Prepares a transaction associated with a given XID.

This is the first phase of the two-phase commit protocol.

xa_commit Commits a transaction associated with a given XID.

This is the second phase of the two-phase commit protocol.

xa_recover Checks a list of prepared transactions and then commits or rolls back according
to the result.

xa_forget Removes logs when a transaction associated with a given XID has already been
handled.

30 Tibero Application Developer's Guide


4.2.2. Properties of the xa_open Function
The following table shows the properties for calling the xa_open function:

Name Mandatory Example Description

user O user=tibero User name with which to connect.

pwd O pwd=1234 Password of a user.

db X db=sample DSN name of a database to be connected (DSN name


in the tbdsn.tbr file).

conn_id X conn_id=db1 Specifies a name for the XA connection.

The name can be used in the AT statement of ESQL.

Loose_Coupling O Loose_Coupling Loosely coupling flag. It can be set to true or false.


=false Determines whether several transaction branches,
included in the same global transaction, share the same
resources.

In the case of loose coupling, two different branches in


a global transaction use resources by allocating two
different transactions, while in the case of tight coupling,
all branches in a global transaction share resources with
one transaction using lock handling.

sestm O sestm=10 Inactive time limit for a transaction before it is aborted


by a system.

Waiting time for the next request after sending a reply


for a former request. If this time expires, it is assumed
that the client has a problem, and the corresponding XA
transaction branch (xtb) is rolled back.

seswt X seswt=30 Waiting time of a database server for a transaction


before XA_RETRY is returned.

If the TMNOWAIT flag is not set, when a database


cannot handle a request of a client immediately, it will
send a reply to the client when the necessary resource
becomes available. If the database cannot handle a
request before the set seswt expires, XARETRY is
returned.

Chapter 4. Using XA 31
4.2.3. XA Application Programming
ESQL is used in general, when an application program is developed in C programming language.

The following is an example of an XA application program, using tbESQL provided in Tibero

#define XA_CONN_STR_TIGHT "TIBERO_XA:user=tibero, pwd=tmax," \


"db=sample, sestm=60"=60"

/* When a global transaction is started in another branch by calling xa_start


* Tight-Coupling
*/
void test_xa_2branch_2pc_tight()
{
int rc;
XID xid1;
XID xid2;
struct xa_switch_t *tbxa = &XA_SWITCH_NAME;
char *conn_str = XA_CONN_STR_TIGHT; /* tightly coupled */
long gtrid = _GTRID_BASE;
long bqual = 1;

EXEC SQL BEGIN DECLARE SECTION;


int cnt;
EXEC SQL END DECLARE SECTION;

/* xa_open */
tbxa->xa_open_entry (conn_str, 0, TMNOFLAGS);
xid1.formatID = 1;
xid1.gtrid_length = sizeof(gtrid);
xid1.bqual_length = sizeof(bqual);
memcpy(&xid1.data[0], &gtrid, sizeof(gtrid));
memcpy(&xid1.data[sizeof(gtrid)], &bqual, sizeof(bqual));

bqual = 2;
xid2.formatID = 1;
xid2.gtrid_length = sizeof(gtrid);
xid2.bqual_length = sizeof(bqual);
memcpy(&xid2.data[0], &gtrid, sizeof(gtrid));
memcpy(&xid2.data[sizeof(gtrid)], &bqual,
sizeof(bqual));

EXEC SQL DELETE FROM PERSON;


EXEC SQL COMMIT WORK;

/* (1, 1) */
/* xa_start -- sql statements starts */

32 Tibero Application Developer's Guide


tbxa->xa_start_entry (&xid1, 0, TMNOFLAGS);
EXEC SQL INSERT INTO PERSON VALUES ('1', 'LEE');
EXEC SQL INSERT INTO PERSON VALUES ('2', 'KIM');

/* xa_end -- */
tbxa->xa_end_entry (&xid1, 0, TMSUCCESS);

/* (1, 2) start */
/* xa_start -- sql statements starts */
tbxa->xa_start_entry (&xid2, 0, TMNOFLAGS);
EXEC SQL INSERT INTO PERSON VALUES ('2', 'PARK');
EXEC SQL INSERT INTO PERSON VALUES ('3', 'JAKE');
EXEC SQL INSERT INTO PERSON VALUES ('4', 'KID');
EXEC SQL INSERT INTO PERSON VALUES ('5', 'CHANHO');

/* xa_end -- */
tbxa->xa_end_entry (&xid2, 0, TMSUCCESS);

/* xa_prepare */
tbxa->xa_prepare_entry (&xid1, 0, TMNOFLAGS);

/* Tightly-Coupled assume */
/* xa_prepare */
tbxa->xa_prepare_entry (&xid2, 0, TMNOFLAGS);

/* xa_commit */
tbxa->xa_commit_entry (&xid1, 0, TMNOFLAGS);

/* xa_commit */
tbxa->xa_commit_entry (&xid2, 0, TMNOFLAGS);
EXEC SQL SELECT COUNT(*) into :cnt FROM PERSON;
CuAssertIntEq(tc, cnt, 6);

/* xa_close */
tbxa->xa_close_entry ("", 0, TMNOFLAGS);
return;
}

/* When a global transaction is started in another branch by calling xa_start


* Loose-Coupling
*/
void test_xa_2branch_2pc_loose(CuTest *tc)
{
int rc;
XID xid1;
XID xid2;
struct xa_switch_t *tbxa = &XA_SWITCH_NAME;

Chapter 4. Using XA 33
char *conn_str = XA_CONN_STR_LOOSE;
long gtrid = _GTRID_BASE;
long bqual = 1;

EXEC SQL BEGIN DECLARE SECTION;


int cnt;
EXEC SQL END DECLARE SECTION;

/* xa_open */
tbxa->xa_open_entry (conn_str, 0, TMNOFLAGS);
xid1.formatID = 1;
xid1.gtrid_length = sizeof(gtrid);
xid1.bqual_length = sizeof(bqual);
memcpy(&xid1.data[0], &gtrid, sizeof(gtrid));
memcpy(&xid1.data[sizeof(gtrid)], &bqual, sizeof(bqual));

bqual = 2;
xid2.formatID = 1;
xid2.gtrid_length = sizeof(gtrid);
xid2.bqual_length = sizeof(bqual);
memcpy(&xid2.data[0], &gtrid, sizeof(gtrid));
memcpy(&xid2.data[sizeof(gtrid)], &bqual,
sizeof(bqual));

EXEC SQL DELETE FROM PERSON;


EXEC SQL COMMIT WORK;

/* (1, 1) start */
/* xa_start -- sql statements starts */
tbxa->xa_start_entry (&xid1, 0, TMNOFLAGS);
EXEC SQL INSERT INTO PERSON VALUES ('1', 'LEE');
EXEC SQL INSERT INTO PERSON VALUES ('2', 'KIM');

/* xa_end -- */
tbxa->xa_end_entry (&xid1, 0, TMSUCCESS);

/* (1, 2) start */
/* xa_start -- sql statements starts */
tbxa->xa_start_entry (&xid2, 0, TMNOFLAGS);
EXEC SQL INSERT INTO PERSON VALUES ('2', 'PARK');
EXEC SQL INSERT INTO PERSON VALUES ('3', 'JAKE');
EXEC SQL INSERT INTO PERSON VALUES ('4', 'KID');
EXEC SQL INSERT INTO PERSON VALUES ('5', 'CHANHO');

/* xa_end -- */
tbxa->xa_end_entry (&xid2, 0, TMSUCCESS);

34 Tibero Application Developer's Guide


/* xa_prepare */
tbxa->xa_prepare_entry (&xid1, 0, TMNOFLAGS);

/* Assumed Loosely-Coupled */
/* xa_prepare */
tbxa->xa_prepare_entry (&xid2, 0, TMNOFLAGS);

/* xa_commit */
tbxa->xa_commit_entry (&xid1, 0, TMNOFLAGS);

/* xa_commit */
tbxa->xa_commit_entry (&xid2, 0, TMNOFLAGS);
EXEC SQL SELECT COUNT(*) into :cnt FROM PERSON;
CuAssertIntEq(tc, cnt, 6);

/* xa_close */
tbxa->xa_close_entry ("", 0, TMNOFLAGS);
return;
}

4.3. JDBC XA
This section describes XA interfaces and an example program using the interfaces.

4.3.1. XA Interface
The JDBC XA interfaces supported in Tibero are:

XA Datasource Interface

XA Connection Interface

XA Exception Interface

XA XID Interface

The following is a list of XA interfaces implemented in Tibero.

Standard XA Interface (JDK 1.3) Tibero XA Interface

javax.sql.XADataSource com.tmax.tibero.jdbc.ext.TbXADataSource

javax.sql.XAConnection com.tmax.tibero.jdbc.ext.TbXAConnection

javax.transaction.xa.XAException com.tmax.tibero.jdbc.ext.TbXAException

Chapter 4. Using XA 35
Standard XA Interface (JDK 1.3) Tibero XA Interface

javax.transaction.xa.Xid com.tmax.tibero.jdbc.ext.TbXid

4.3.2. XA Interface Programming


The following is an example program using XA interfaces in a tbJDBC environment.

package test.com.tmax.tibero.cases;
import com.tmax.tibero.jdbc.ext.*;
import test.com.tmax.tibero.AbstractBase;
import javax.sql.XAConnection;
import javax.transaction.xa.XAResource;
import java.sql.*;

public class TestXATwoBranch extends AbstractBase{


int formatID = 1;
int row_count = 0;
int pre1 , pre2 = 0;

byte[] gtid1 = new byte[1];


byte[] bq1 = new byte[1];
byte[] gtid2 = new byte[1];
byte[] bq2 = new byte[1];

public TestXATwoBranch (String name) {


super(name);
}

/* When tightly coupled */


public void test_xa_2branch_2pc_tight () throws Exception {
debug("test_xa_2branch_2pc_tight " + this._getClassName());

create_table_for_xa();

gtid1[0] = (byte)1; bq1[0] = (byte)1;


gtid2[0] = (byte)1; bq2[0] = (byte)2;

TbXADataSource xads1 = new TbXADataSource();


xads1.setUrl(getXAurl());
xads1.setUser(getXAuser());
xads1.setPassword(getXApasswd());

TbXADataSource xads2 = new TbXADataSource();


xads2.setUrl(getXAurl());
xads2.setUser(getXAuser());

36 Tibero Application Developer's Guide


xads2.setPassword(getXApasswd());

XAConnection xacon1 = xads1.getXAConnection();


XAConnection xacon2 = xads2.getXAConnection();

Connection conn1 = xacon1.getConnection();


Connection conn2 = xacon2.getConnection();

XAResource xars1 = xacon1.getXAResource();


XAResource xars2 = xacon2.getXAResource();

/* XID (1.1) creation */


TbXid xid1 = new TbXid(formatID, gtid1,bq1 );

/* XID (1.2) creation */


TbXid xid2 = new TbXid(formatID, gtid2, bq2);
try {
/* (1.1) creation */
xars1.start(xid1, XAResource.TMNOFLAGS);

PreparedStatement pstmt1;
pstmt1 = conn1.prepareStatement(
"insert into author values (?,?)");

pstmt1.setInt(1, 1);
pstmt1.setString(2, "FOSCHIA");
pstmt1.executeUpdate();

pstmt1.setInt(1,2);
pstmt1.setString(2, "AGNOS");
pstmt1.executeUpdate();

/* (1.1) end */
xars1.end(xid1, XAResource.TMSUCCESS);

/* (1.2) start */
xars2.start(xid2, XAResource.TMNOFLAGS);
PreparedStatement pstmt2;
pstmt2 = conn2.prepareStatement(
"insert into author values (?,?)");

pstmt2.setInt(1, 3);
pstmt2.setString(2, "JELLA");
pstmt2.executeUpdate();

pstmt2.setInt(1,4);
pstmt2.setString(2, "THIPHILO");

Chapter 4. Using XA 37
pstmt2.executeUpdate();

/* (1.2) end */
xars2.end(xid2, XAResource.TMSUCCESS);

/* (1,1) prepare */
pre1= xars1.prepare(xid1);
assertEquals(pre1, XAResource.XA_RDONLY);

/* (1,2) prepare */
pre2 = xars2.prepare(xid2);
assertEquals(pre2, XAResource.XA_OK);

/* (1.1) commit */
try {
xars1.commit(xid1, false);
} catch(TbXAException e) {}

/* (1.2) commit */
try {
xars2.commit(xid2, false);
} catch(TbXAException e) {}

Statement stmt1 = conn1.createStatement();


ResultSet rs1 =
stmt1.executeQuery("select * from author");

while (rs1.next())
row_count ++;

assertEquals(4, row_count);

rs1.close(); rs1 = null;


stmt1.close(); stmt1 = null;

pstmt1.close(); conn1.close(); xacon1.close();


pstmt2.close(); conn2.close(); xacon2.close();

pstmt1= null; conn1= null; xacon1=null;


pstmt2= null; conn2= null; xacon2=null;
} catch (TbXAException e) {}
}

/* When loosely coupled */


public void test_xa_2branch_2pc_loose () throws Exception {
debug("test_xa_2branch_2pc_loose " + this._getClassName());

38 Tibero Application Developer's Guide


create_table_for_xa();

gtid1[0] = (byte)1; bq1[0] = (byte)1;


gtid2[0] = (byte)1; bq2[0] = (byte)2;

TbXADataSource xads1 = new TbXADataSource();

xads1.setUrl(getXAurl());
xads1.setUser(getXAuser());
xads1.setPassword(getXApasswd());

TbXADataSource xads2 = new TbXADataSource();

xads2.setUrl(getXAurl());
xads2.setUser(getXAuser());
xads2.setPassword(getXApasswd());

XAConnection xacon1 = xads1.getXAConnection();


XAConnection xacon2 = xads2.getXAConnection();

Connection conn1 = xacon1.getConnection();


Connection conn2 = xacon2.getConnection();

XAResource xars1 = xacon1.getXAResource();


XAResource xars2 = xacon2.getXAResource();

TbXid xid1 = new TbXid(formatID, gtid1,bq1 );


TbXid xid2 = new TbXid(formatID, gtid2, bq2);

try {
xars1.start(xid1, TbXAResource.TBRTRANSLOOSE);

PreparedStatement pstmt1;
pstmt1 = conn1.prepareStatement(
"insert into author values (?,?)");

pstmt1.setInt(1, 1);
pstmt1.setString(2, "FOSCHIA");
pstmt1.executeUpdate();

pstmt1.setInt(1,2);
pstmt1.setString(2, "AGNOS");
pstmt1.executeUpdate();

xars1.end(xid1, XAResource.TMSUCCESS);

xars2.start(xid2, TbXAResource.TBRTRANSLOOSE);

Chapter 4. Using XA 39
PreparedStatement pstmt2;
pstmt2 = conn2.prepareStatement(
"insert into author values (?,?)");

pstmt2.setInt(1, 3);
pstmt2.setString(2, "JELLA");
pstmt2.executeUpdate();

pstmt2.setInt(1,4);
pstmt2.setString(2, "THIPHILO");
pstmt2.executeUpdate();

xars2.end(xid2, XAResource.TMSUCCESS);

pre1= xars1.prepare(xid1);
assertEquals(pre1, XAResource.XA_OK);

pre2 = xars2.prepare(xid2);
assertEquals(pre2, XAResource.XA_OK);

xars1.commit(xid1, false);
xars2.commit(xid2, false);

Statement stmt1 = conn1.createStatement();


ResultSet rs1 =
stmt1.executeQuery("select * from author");

while (rs1.next())
row_count ++;

assertEquals(4, row_count);

rs1.close(); rs1 = null;


stmt1.close(); stmt1 = null;

pstmt1.close(); conn1.close(); xacon1.close();


pstmt2.close(); conn2.close(); xacon2.close();

pstmt1= null; conn1= null; xacon1=null;


pstmt2= null; conn2= null; xacon2=null;
} catch (TbXAException e) {}
}
}

40 Tibero Application Developer's Guide


4.4. Integration of TP-Monitor and Tibero
TP-Monitor (Transaction Processing Monitor) is a middleware for managing transactions. It consistently
keeps and maintains transactions by monitoring each transaction, which is the minimum handling unit for
sessions, systems, and databases that use various protocols.

This section describes Tmax and Tuxedo, which are superior commercial TP-monitors, and example
programs that integrate them with Tibero.

4.4.1. Integration of Tmax and Tibero


Tmax stands for Transaction Maximization. As a TP-Monitor, it not only guarantees that transactions are
perfectly handled between heterogeneous systems, but it also distributes loads and handles errors.
Furthermore, it supports various characteristics of transactions, offers optimal development environment
to the users, provides best solutions in the client/server environment with high performance, and handles
all types of failures.

Tmax complies with the X/Open DTP (Distributed Transaction Processing) model which is the international
standard for distributed transaction processing. It has been developed according to APIs for the OSI(Open
Systems Interconnection group) DTP services and system interface definitions. In addition, it supports
transparent business handling between heterogeneous systems in the distributed environment and OLTP
(On-Line Transaction Processing), and meets the ACID (Atomic, Consistent, Isolated, Durable: transaction
properties) characteristics for transaction handling.

To test the following example program integrating Tmax with Tibero, Tmax and Tibero should first be
properly installed.

Note

1. If Tmax and Tibero to be integrated, are installed in separate machines, Tibero client must be
installed in the machine in which Tmax is installed. The client also needs to be able to access the
Tibero server.

2. For detailed information on how to install and manage Tmax, refer to the "Tmax Installation Guide"
and "Tmax Administration Guide". For detailed information on how to install and manage Tibero,
refer to the "Tibero Installation Guide" and "Tibero Administrator's Guide."

The following example program is provided by the Tmax installer, by default. The program illustrates how
a client accesses Tibero DB to search, add, modify, and delete data in a certain table via Tmax server.
Descriptions for the test environment and each file used by the program are as follows:

Test environment

Classification Description

OS Ubuntu Linux 2.6.32-24-server x86-64

Chapter 4. Using XA 41
Classification Description

Shell bash

$TMAXDIR Tmax installation directory

Files

File Description

sample.m Tmax configuration file ($TMAXDIR/config)

tms_tbr.mk TMS makefile for Tibero ($TMAXDIR/sample/server)

tbrtest.tbc Server program's tbESQL/C file ($TMAXDIR/sample/server)

tbrtest.h Server program's header file ($TMAXDIR/sample/server)

Makefile.tbr Server program's makefile ($TMAXDIR/sample/server)

compile Server program's build script ($TMAXDIR/sample/server)

tbr_main.c Client program's program file ($TMAXDIR/sample/client)

Makefile.c Client program's makefile ($TMAXDIR/sample/client)

compile Client program's build script ($TMAXDIR/sample/client)

Tmax can be integrated with Tibero in the following order:

1. Configuring Tmax

2. Compiling TMS

3. Compiling a server program

4. Compiling a client program

5. Creating a DB table

6. Executing an example program

Configuring Tmax
Setting the Tmax configuration file

sample.m under the $TMAXDIR/config directory is the ASCII type Tmax configuration file that includes
information for starting Tmax. After the file is compiled with the cfl utility, a binary file is created. The
binary file is accessed when Tmax is started and terminated.

42 Tibero Application Developer's Guide


To activate a service to be integrated with Tibero server, modify the SVRGROUP, SERVER, and
SERVICE sections in sample.m file as follows:

### tms for Tibero ###


svg4 NODENAME = "integrity", DBNAME = TIBERO,
OPENINFO = "TIBERO_XA:user=tibero,pwd=tmax,sestm=60,db=tibero",
TMSNAME = tms_tbr

### server for Tibero sample program ###


tbrtest SVGNAME = svg4

### services for tbrtest ###


TBRINS SVRNAME = tbrtest
TBRSEL SVRNAME = tbrtest
TBRUPT SVRNAME = tbrtest
TBRDEL SVRNAME = tbrtest

NODENAME in the SVRGROUP section is automatically set as the hostname value during the Tmax
installation. DBNAME, used to distinguish a DB vendor, is set to TIBERO. OPENINFO is set to
TIBERO_XA, used for setting XA mode, followed by values for properties described in 4.2.2. Properties
of the xa_open Function. TMSNAME is set to an XA module name. In the SERVER section, the name
of the example server program is set to tbrtest.

In the SERVICE section, four services provided by the example server program are set.

Note

For detailed information on how to set Tmax configuration file, refer to the "Tmax Administration
Guide."

Compiling the Tmax configuration file

Compile the modified sample.m with the following command:

cfl -i sample.m

If the file compiles successfully, the following message will be displayed:

CFL is done successfully for node(<nodename>)

Creating a service table

A service table is a file needed to creating server processes in each Tmax system. It includes information
about the services each process handles. Create the service table with the following command:

gst

If the service table is successfully created, the following message will be displayed:

Chapter 4. Using XA 43
SVC tables are successfully generated GST is successfully done

Creating a binary file for defining structures and a binary file for defining field keys

If a structure or a field key is used in a server or a client program, a corresponding binary file should
be created. This process is skipped in the example program as the program does not use a structure
or a field key.

Compiling TMS
As a Tmax system's component, TMS (Transaction Management Server) is a process that manages
databases and handles distributed transactions. Before compiling TMS for Tibero, check whether
Tibero-related environment variables such as TB_HOME, TB_SID, LD_LIBRARY_PATH, and PATH are
properly set.

Move to the $TMAXDIR/sample/server directory to compile TMS with TMS makefile for Tibero as follows:

cd $TMAXDIR/sample/server
make f tms_tbr.mk all

Compiling a server program


Move to the $TMAXDIR/sample/server directory to compile a server program that provides actual services
using a build script as follows:

cd $TMAXDIR/sample/server
./compile tbc tbrtest

Compiling a client program


Move to the $TMAXDIR/sample/server directory to compile a client program that requests services using
a build script as follows:

cd $TMAXDIR/sample/client
./compile c tbr_main

Creating a DB table
Access Tibero server using the tibero/tmax account to create the emp table as follows:

tbsqltibero/tmax

create table emp (


empno number,

44 Tibero Application Developer's Guide


ename char(16),
job char(16),
hiredate char(16),
sal number
);

Executing an Example program


Starting Tmax system

Start Tmax with the following command:

tmboot

If Tmax successfully starts, the following message will be displayed:

TMBOOT for node(<nodename>) is starting:


Welcome to Tmax demo system: it will expire 2012/3/11
Today: 2012/1/13
TMBOOT: TMM is starting: Fri Jan 13 14:18:31 2012
TMBOOT: CLL is starting: Fri Jan 13 14:18:31 2012
TMBOOT: CLH is starting: Fri Jan 13 14:18:31 2012
(I) CLH9991 Current Tmax Configuration: Number of client handler(MINCLH) = 1
Supported maximum user per node = 680
Supported maximum user per handler = 680 [CLH0125]
TMBOOT: TLM(tlm) is starting: Fri Jan 13 14:18:31 2012
TMBOOT: TMS(tms_tbr) is starting: Fri Jan 13 14:18:31 2012
(I) TMS0211 General Infomation : transaction recovery will be started [TMS0221]
(I) TMS0211 General Infomation : transaction recovery was completed [TMS0222]
TMBOOT: TMS(tms_tbr) is starting: Fri Jan 13 14:18:31 2012
TMBOOT: SVR(tbrtest) is starting: Fri Jan 13 14:18:31 2012

Executing a client program

A client program has the following command options:

Usage: ./tbr_main empno loop_cnt ins_flag upt_flag del_flag


flag : 1|0

Select desired options and execute a client program, and the following result will be displayed:

./tbr_main 12 3 1 0 0

LOOP COUNT = 1
>> INSERT : COMMIT TEST
[./tbr_main] [[TBRINS] emp Insert Success]
[./tbr_main] [[TBRSEL] emp Select Success [1]]

Chapter 4. Using XA 45
LOOP COUNT = 2
>> INSERT : COMMIT TEST
[./tbr_main] [[TBRINS] emp Insert Success]
[./tbr_main] [[TBRSEL] emp Select Success [2]]

LOOP COUNT = 3
>> INSERT : COMMIT TEST
[./tbr_main] [[TBRINS] emp Insert Success]
[./tbr_main] [[TBRSEL] emp Select Success [3]]

4.4.2. Integration of Tuxedo and Tibero


As a platform for handling distributed transactions, Tuxedo provides mainframe's scalability and
high-performance in open distributed systems for programs written in C, C++, and COBOL. It can also
rehost mainframe applications on mainstream hardware.

Tuxedo not only provides reliability and scalability in a cost-effective way for supporting hundreds of
thousands of transactions, but it also extends the lifecycle of existing IT resources that are a part of an
innovative architecture such as SOA. Oracle Tuxedo is a Oracle Fusion Middleware product for handling
transactions.

To test the following example program integrating Tuxedo with Tibero, Tuxedo and Tibero should be
properly installed.

Note

1. If Tuxedo and Tibero to be integrated are installed in separate machines, Tibero client must be
installed in the machine in which Tuxedo is installed, and the client needs to be able to access the
Tibero server.

2. For detailed information on how to install and manage Tuxedo, refer to the Tuxedo documentation.
For detailed information on how to install and manage Tibero, refer to the "Tibero Installation Guide"
and "Tibero Administrator's Guide."

The following example program illustrates how a client accesses Tibero DB to search and add data in a
certain table via Tuxedo server. For convenience, assume that the host name of the test server is
tux_machine, Tibero and Tuxedo are installed in path/to/tibero and /path/to/tuxedo respectively, and
relevant files are located in /path/to/example.

Descriptions for the test environment and each file used by the program are as follows:

Test environment

46 Tibero Application Developer's Guide


Classification Description

OS AIX

Host name tux_machine

Shell bash

Tibero installation directory /path/to/tibero

Tuxedo installation directory /path/to/tuxedo

Example program's home /path/to/example


directory

Files

File Description

tb_tux.env System environment variable configuration file

tb_tux.conf.m Tuxedo configuration file

tmax32.fld Field table file

trans_fml32.tbc Server program's tbESQL/C file

builds.sh Server program's build script

insert.c INSERT client program file

select.c SELECT client program file

buildc.sh Client program's build script

create_table.sql File for creating a DB table for a test

run.sh Script for starting Tuxedo system

Note

To see the full source code of this example program, refer to Appendix B. Example of Integrating
Tibero with Tuxedo.

Tuxedo can be integrated with Tibero in the following order. Depending on the OS and the system
environment, the example files should be modified accordingly.

1. Setting system environment variables

2. Configuring Tuxedo

3. Compiling TMS

4. Compiling a server program

Chapter 4. Using XA 47
5. Compiling client programs

6. Creating a DB table

7. Executing an example program

Setting system environment variables


To test the integration with Tibero and Tuxedo, set the following system environment variables:

Setting basic environment variables for Tibero

export TB_HOME=/path/to/tibero
export TB_SID=tibero
export PATH=$TB_HOME/bin:$TB_HOME/client/bin:$TB_HOME/scripts:$PATH
export LD_LIBRARY_PATH=$TB_HOME/client/lib:$TB_HOME/lib:$LD_LIBRARY_PATH
export LIBPATH=$TB_HOME/client/lib:$TB_HOME/lib:$LIBPATH

Setting basic environment variables for Tuxedo

export TUXDIR=/path/to/tuxedo
export JAVA_HOME=$TUXDIR/jre
export JVMLIBS=$JAVA_HOME/lib/amd64/server:$JAVA_HOME/jre/bin
export PATH=$TUXDIR/bin:$JAVA_HOME/bin:$PATH
export COBCPY=:$TUXDIR/cobinclude; export COBCPY
export COBOPT="-C ANS85 -C ALIGN=8 -C NOIBMCOMP -C TRUNC=ANSI -C OSEXT=cbl"
export SHLIB_PATH=$TUXDIR/lib:$JVMLIBS:$SHLIB_PATH
export LIBPATH=$TUXDIR/lib:$JVMLIBS:$LIBPATH
export LD_LIBRARY_PATH=$TUXDIR/lib:$JVMLIBS:$LD_LIBRARY_PATH
export WEBJAVADIR=$TUXDIR/udataobj/webgui/java

Setting additional environment variables for Tuxedo

To test the integration, set the following additional environment variables according to each environment.

export TUXCONFIG=/path/to/tuxedo/tuxconf
export FLDTBLDIR32=/path/to/tuxedo
export FIELDTBLS32=tmax32.fld
export TLOGDEVICE=/path/to/tuxedo/TLOG
export ULOGPFX=/path/to/tuxedo/ULOG

Configuring Tuxedo
Setting the Tuxedo configuration file

48 Tibero Application Developer's Guide


tb_tux.conf.m is the ASCII type Tuxedo configuration file that includes information about starting Tuxedo.
After the file is compiled with the tmloadcf utility, a binary file is created. The binary file is accessed
when Tuxedo is started and terminated.

To activate a service to be integrated with Tibero server, modify the RESOURCES, MACHINES,
GROUPS, SERVERS, and SERVICES sections in tb_tux.conf.m as follows:

*RESOURCES
IPCKEY 68300
DOMAINID tbrdomain
MASTER tbrtest
MAXACCESSERS 10
MAXSERVERS 5
MAXSERVICES 10
MODEL SHM
LDBAL N

*MACHINES
DEFAULT:
TUXDIR="path/to/tuxedo"
APPDIR="path/to/example"
TUXCONFIG="path/to/example/tuxconf"

tux_machine LMID=tbrtest

*GROUPS
TBXA LMID=tbrtest GRPNO=1
TMSNAME=tms_tibero
OPENINFO="TIBERO_XA:TIBERO_XA:user=sys,pwd=tibero,
sestm=60,db=tibero"

*SERVERS
DEFAULT:
CLOPT="-A -r"
trans_fml32 SRVGRP=TBXA SRVID=1

*SERVICES
SELECT_FML32
INSERT_FML32
~

The RESOURCES and MACHINES sections are the same as in a general Tuxedo configuration file.

tux_machine, the host name in the MACHINE section should be modified according to each test
environment. tbrtest for LMID and MASTER and tbrdomain for DOMAINID can be modified.

The GROUPS section is the same as in a general Tuxedo configuration file. TMSNAME is set as a XA
module name used to communicate with the Tibero server. OPENINFO is set to

Chapter 4. Using XA 49
"'TIBERO_XA:TIBERO_XA:" which sets the XA mode, followed by property values of the 4.2.2.
Properties of the xa_open Function.

In the SERVERS section, trans_fml32, the name of the example server program, is set. In the SERVICE
section, services provided by the example server program are set to SELECT_FML32 and
INSERT_FML32.

Note

For detailed information on how to set Tuxedo configuration file, refer to the Tuxedo documentation.

Compile the modified tb_tux.conf.m with the following command:

tmloadcf -y tb_tux.conf.m

Convert a field table file to a header file.

Common structures are defined and used for data transfer between a server and a client.

In this example program, tmax32.fld, the following field table file, is newly defined, using the Field
Manipulation Language (FLM), and used.

#name number type flag comment


OUTPUT 302 string 0 -
EMPNO 901 long 0 -
ENAME 902 string 0 -
JOB 903 string 0 -
MGR 904 long 0 -
SAL 905 float 0 -
COMM 906 float 0 -
DEPTNO 907 long 0 -

Convert tmax32.fld to a header file with the following command:

mkfldhdr32 tmax32.fld

A header file named tmax32.fld.h is created as a result and is used by the example programs. For
information on how to define other structures and create a field table file, refer to the Tuxedo
documentation.

Compiling TMS
Compile TMS for Tibero with the following command:

buildtms -o $TUXDIR/bin/tms_tibero -v -r TIBERO_XA

50 Tibero Application Developer's Guide


Compiling a server program
Compile a server program that provides actual services with the following build script, builds.sh.

#### transaction server precompile ####


PRECOMP=$TB_HOME/client/bin/tbpc
PRECOMPFLAGS="UNSAFE_NULL=YES"
LIB=$TB_HOME/client/lib
INC=$TB_HOME/client/include
CFLAGS="-ltbcli -ltbxa -lm -lrt -lpthread -ltbertl -g "
CC=gcc
rm -f trans_fml32.c
$PRECOMP INCLUDE=$TUXDIR/include UNSAFE_NULL=YES INCLUDE=$INC
$PRECOMPFLAGS ONAME=trans_fml32.c trans_fml32.tbc

#### transaction server build ####


buildserver -o trans_fml32 -v -f trans_fml32.c -s INSERT_FML32,
SELECT_FML32 -r TIBERO_XA

Note

For detailed information on precompiler options, refer to the "TiberotbESQL/C Guide."

Compiling client programs


Compile client programs, that request insert and select services, with a build script as follows:

buildclient -o insert -v -f insert.c


buildclient -o select -v -f select.c

Creating a DB table
Access Tibero server using the tibero/tmax account to create the emp table as follows:

tbsqltibero/tmax

drop table emp;


CREATE TABLE emp (
empno NUMBER,
ename VARCHAR2(10),
job VARCHAR2(9),
mgr NUMBER(4),
hiredate DATE,

Chapter 4. Using XA 51
sal NUMBER(7,2),
comm NUMBER(7,2),
deptno NUMBER(2)
);

Executing an example program


Starting Tuxedo system

Start Tuxedo with the following command:

tmboot -y

If Tuxedo successfully starts, the following message will be displayed:

Booting all admin and server processes in /path/to/example/tuxconf


INFO: Oracle Tuxedo, Version 10.3.0.0, 64-bit, Patch Level (none)

Booting admin processes ...

exec BBL -A :
process id=3457104 ... Started.

Booting server processes ...

exec tms_tibero -A :
process id=4046910 ... Started.
exec tms_tibero -A :
process id=9265576 ... Started.
exec tms_tibero -A :
process id=1863802 ... Started.
exec trans_fml32 -A -r :
process id=3719284 ... Started.
5 processes started.

Executing a client program

Execute a client program to add employee information to the emp table as follows:

./insert
******************************************
| Employee Number : 1
| Employee Name : Kim
| Employee Job : Manager

52 Tibero Application Developer's Guide


******************************************

If the insert program is executed, and Employee Number, Employee Name, and Employee Job values
are entered as shown in the previous example, a record is added to the emp table in the Tibero server
using the Tuxedo server program.

./select
******************************************
| Employee Number : 1
******************************************

EMPNO: 1
ENAME: Kim
JOB: Manager

If the select program is executed, and a value for Employee Number is entered as shown in the previous
example, a corresponding record is fetched from the emp table in the Tibero server and displayed using
the Tuxedo server program.

Chapter 4. Using XA 53
Chapter 5. Using mod_tbPSM

To request HTTP pages via a web browser, Tibero RDBMS 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. Therefore, Apache HTTP server
must already be installed.

5.1. Installing Apache HTTP Server


The version of Apache HTTP server optimized for mod_tbPSM is 2.2.21.

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

http://projects.apache.org/projects/http_server.html

In UNIX, it is needed to download the source code and manually build it. In Windows, it is only needed
to install the provided installation binary.

5.2. Registering mod_tbPSM


After Apache HTTP server is installed, modify Apache configuration file, $(Apache server installation
path)/conf/httpd.conf, and then register 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 a dll file is used, add the following:

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

Chapter 5. Using mod_tbPSM 55


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 segment in the Apache configuration file should be identical as the previous example.

5.3. Writing and Executing a Procedure


This section describes how to write 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 the "Tibero RDBMS tbPSM Reference Guide."

5.3.1. Writing 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;

56 Tibero Application Developer's Guide


END;
/

Description of the previous example is as follows:

1. 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.

2. 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.3.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)&...

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, ... , Parameter names of a procedure. In the URL address format, these
parametern 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:

Chapter 5. Using mod_tbPSM 57


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

If the above 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.

58 Tibero Application Developer's Guide


Appendix A. tbJDBC Example

This appendix provies the entire source code of an example program written using tbJDBC

A.1. JdbcTest.class
The following is a sample source code that creates a JdbcTest class file using tbJDBC.

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;

public class JdbcTest


{
Connection conn;

public static void main(String[] args) throws Exception


{
JdbcTest test = new JdbcTest();

test.connect();
test.executeStatement();
test.executePreparedStatement();
test.executeCallableStatement();
test.disconnect();
}

private void connect() throws SQLException, ClassNotFoundException


{
Class.forName("com.tmax.tibero.jdbc.TbDriver");

conn = DriverManager.getConnection(
"jdbc:tibero:thin:@localhost:6666:tibero",
"tibero", "tmax");

if (conn == null)
{

Appendix A. tbJDBC Example 59


System.out.println("connection failure!");
System.exit(-1);
}
System.out.println("Connection success!");
}

private void executeStatement() throws SQLException


{
String dropTable = "drop table emp";
String createTable = "create table emp (id number, "+
" name varchar(20), salary number)";
String InsertTable = "insert into emp values(1000, 'Park', 5000)";

Statement stmt = conn.createStatement();

try {
stmt.executeUpdate(dropTable);
} catch(SQLException e) {
// if there is not the table
}

stmt.executeUpdate(createTable);
stmt.executeUpdate(InsertTable);

stmt.close();
}

private void executePreparedStatement() throws SQLException


{
PreparedStatement pstmt = conn
.prepareStatement("select name from emp where id = ?");

pstmt.setString(1, "1000");

ResultSet rs = pstmt.executeQuery();

while (rs.next()) {
System.out.println(rs.getString(1));
}
pstmt.close();
}

private void executeCallableStatement() throws SQLException


{
String callSQL = " CREATE PROCEDURE testProc "+
" (ID_VAL IN NUMBER, SAL_VAL IN OUT NUMBER) as " +
" BEGIN" +

60 Tibero Application Developer's Guide


" update emp" +
" set salary = SAL_VAL" +
" where id = ID_VAL;" +
" select salary into SAL_VAL" +
" from emp" +
" where id = ID_VAl;" +
" END;";

String dropProc = "DROP PROCEDURE testProc";

Statement stmt = conn.createStatement();

try {
stmt.executeUpdate(dropProc);
} catch(SQLException e) {
// if there is not the procedure
}

stmt.executeUpdate(callSQL);

CallableStatement cstmt = conn.prepareCall("{call testProc(?, ?)}");


cstmt.setInt(1, 1000);
cstmt.setInt(2, 7000);
cstmt.registerOutParameter(2, Types.INTEGER);
cstmt.executeUpdate();

int salary = cstmt.getInt(2);


System.out.println(salary);

stmt.close();
cstmt.close();
}

private void disconnect() throws SQLException


{
if (conn != null)
conn.close();
}
}

Appendix A. tbJDBC Example 61


Appendix B. Example of Integrating Tibero
with Tuxedo

This appendix provides the source code of an example program that integrates Tibero with Tuxedo and
relevant scripts in various formats.

B.1. tb_tux.env
The following is a configuration file that contains the system environment variables.

# for tibero
export TB_HOME=/path/to/tibero
export TB_SID=tibero
export PATH=$TB_HOME/bin:$TB_HOME/client/bin:$TB_HOME/scripts:$PATH
export LD_LIBRARY_PATH=$TB_HOME/client/lib:$TB_HOME/lib:$LD_LIBRARY_PATH
export LIBPATH=$TB_HOME/client/lib:$TB_HOME/lib:$LIBPATH

# for tuxedo
export TUXDIR=/path/to/tuxedo
export JAVA_HOME=$TUXDIR/jre
export JVMLIBS=$JAVA_HOME/lib/amd64/server:$JAVA_HOME/jre/bin
export PATH=$TUXDIR/bin:$JAVA_HOME/bin:$PATH
export COBCPY=:$TUXDIR/cobinclude; export COBCPY
export COBOPT="-C ANS85 -C ALIGN=8 -C NOIBMCOMP -C TRUNC=ANSI -C OSEXT=cbl"
export SHLIB_PATH=$TUXDIR/lib:$JVMLIBS:$SHLIB_PATH
export LIBPATH=$TUXDIR/lib:$JVMLIBS:$LIBPATH
export LD_LIBRARY_PATH=$TUXDIR/lib:$JVMLIBS:$LD_LIBRARY_PATH
export WEBJAVADIR=$TUXDIR/udataobj/webgui/java

export TUXCONFIG=/path/to/tuxedo/tuxconf
export FLDTBLDIR32=/path/to/tuxedo
export FIELDTBLS32=tmax32.fld
export TLOGDEVICE=/path/to/tuxedo/TLOG
export ULOGPFX=/path/to/tuxedo/ULOG

B.2. tb_tux.conf.m
The following is a Tuxedo configuration file.

Appendix B. Example of Integrating Tibero with


Tuxedo 63
*RESOURCES
IPCKEY 68300

DOMAINID tbrdomain
MASTER tbrtest
MAXACCESSERS 10
MAXSERVERS 5
MAXSERVICES 20
MODEL SHM
LDBAL N

*MACHINES
DEFAULT:
TUXDIR="/data1/apmqam/oracle/tuxedo/tuxedo10gR3"
APPDIR="/data1/apmqam/tibero_tuxedo_test"
TUXCONFIG="/data1/apmqam/tibero_tuxedo_test/tuxconf"
TLOGDEVICE="/data1/apmqam/tibero_tuxedo_test/TLOG"

tmaxi4 LMID=tbrtest

*GROUPS
TBXA LMID=tbrtest GRPNO=1
TMSNAME=tms_tibero
OPENINFO="TIBERO_XA:TIBERO_XA:user=sys,pwd=tibero,
sestm=60,db=tibero"

*SERVERS
DEFAULT:
CLOPT="-A -r"

trans_fml32 SRVGRP=TBXA SRVID=1

*SERVICES
SELECT_FML32
INSERT_FML32

B.3. tmax32.fld
The following is a field table file.

#name number type flag comment


OUTPUT 302 string 0 -
EMPNO 901 long 0 -
ENAME 902 string 0 -
JOB 903 string 0 -
MGR 904 long 0 -

64 Tibero Application Developer's Guide


SAL 905 float 0 -
COMM 906 float 0 -
DEPTNO 907 long 0 -

B.4. trans_fml32.tbc
The following is a server program's tbESQL/C file.

#include <stdio.h>
#include <atmi.h>
#include <userlog.h>
#include <Uunix.h>
#include <fml32.h>
#include "fml32.fld.h"
#include <tx.h>
#include "sqlca.h"

EXEC SQL include SQLCA.H;

EXEC SQL begin declare section;


int h_empno;
char h_ename[10];
char h_job[10];
EXEC SQL end declare section;

void INSERT_FML32(rqst)
TPSVCINFO *rqst;
{
FBFR32 *sndbuf;
char msgbuf[256];
FLDLEN32 flen;
XID *xid;
TXINFO info;
char xidstring[1000];
char str[100];

int i;

sndbuf = (FBFR32 *)rqst->data;

tx_info(&info);
xid = &(info.xid);

memset( xidstring, 0x00, 1000);

for( i = 0 ; i < xid->gtrid_length+xid->bqual_length ; i++ )

Appendix B. Example of Integrating Tibero with


Tuxedo 65
{
sprintf(xidstring+strlen(xidstring),"%0x\0",xid->data[i]);
}

Fprint32(sndbuf);
memset( &h_empno, 0x00, sizeof ( h_empno ) );
memset( h_ename, 0x00, sizeof ( h_ename ) );
memset( h_job, 0x00, sizeof ( h_job ) );

Fget32(sndbuf, EMPNO, 0, (char *)&h_empno, &flen);


Fget32(sndbuf, ENAME, 0, (char *)h_ename, &flen);
Fget32(sndbuf, JOB, 0, (char *)h_job, &flen);

printf("SVR: EMPNO %d ENAME %s JOB %s\n", h_empno, h_ename, h_job);


printf("SVR: INSERT_FML32 XID:%d.%d. %0x.%s - %s\n\n",
xid->gtrid_length, xid->bqual_length,
xid->formatID, xidstring, h_ename);

EXEC SQL INSERT


INTO emp( empno, ename, job )
VALUES ( :h_empno, :h_ename, :h_job );

if ( sqlca.sqlcode != 0 ){
sprintf(msgbuf, "insert fail: sqlcode = %d(%s)\n",
sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
Fchg32(sndbuf, OUTPUT, 0, msgbuf, 0);
tpreturn(TPFAIL, -1, (char *)sndbuf, 0, 0);
}

strcpy(msgbuf, "insert success!" );


Fchg32(sndbuf, OUTPUT, 0, msgbuf, 0);
tpreturn(TPSUCCESS, 0, rqst->data, strlen(rqst->data), 0);
}

void SELECT_FML32(rqst)
TPSVCINFO *rqst;
{
FBFR32 *sndbuf;
char msgbuf[256];
FLDLEN32 flen;

sndbuf = (FBFR32 *)rqst->data;


Fprint32(sndbuf);
Fget32(sndbuf, EMPNO, 0, (char *)&h_empno, &flen);

EXEC SQL SELECT NVL(ename,' '), NVL(job,' ')


INTO :h_ename,:h_job

66 Tibero Application Developer's Guide


FROM emp
WHERE empno = :h_empno;

if ( sqlca.sqlcode != 0 ){
sprintf(msgbuf, "select failed sqlcode = %d(%s)\n",
sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
Fchg32(sndbuf, OUTPUT, 0, msgbuf, 0);
tpreturn(TPFAIL, -1, (char *)sndbuf, 0, 0);
}

printf("#### %d \n", h_empno);


Fchg32(sndbuf, ENAME, 0,(char *)h_ename, 0);
Fchg32(sndbuf, JOB, 0, (char *)h_job, 0);
Fchg32(sndbuf, EMPNO, 0, (char *)&h_empno, 0);

strcpy(msgbuf, "select success!" );


Fchg32(sndbuf, OUTPUT, 0, msgbuf, 0);

Fprint32(sndbuf);
tpreturn(TPSUCCESS, 0,(char *)sndbuf, sizeof(sndbuf), 0);
}

B.5. builds.sh
The following is a server program's build script.

#### transaction server precompile ####


PRECOMP=$TB_HOME/client/bin/tbpc
PRECOMPFLAGS="UNSAFE_NULL=YES"
LIB=$TB_HOME/client/lib
INC=$TB_HOME/client/include
CFLAGS="-ltbcli -ltbxa -lm -lrt -lpthread -ltbertl -g "
CC=gcc
rm -f trans_fml32.c
$PRECOMP INCLUDE=$TUXDIR/include UNSAFE_NULL=YES INCLUDE=$INC $PRECOMPFLAGS ONAME=t
rans_fml32.c trans_fml32.tbc

#### transaction server build ####


buildserver -o trans_fml32 -v -f trans_fml32.c -s INSERT_FML32,SELECT_FML32 -r TIBE
RO_XA

B.6. insert.c
The following is a client program file, INSERT.

Appendix B. Example of Integrating Tibero with


Tuxedo 67
#include <stdio.h>
#include <atmi.h>
#include <fml32.h>
#include <string.h>
#include "fml32.fld.h"

struct temp_str{
int empno;
char ename[11];
char job[10];
};
typedef struct temp_str *str;

main(argc, argv)
char *argv[];
{
FBFR32 *sendbuf;
FBFR32 *recvbuf;
long recvlen = 0;
int ret;
str tmpbuf;
char msgbuf[30];
FLDLEN32 flen;

tmpbuf = malloc(sizeof(struct temp_str));

if (tpinit((TPINIT *) NULL) == -1) {


fprintf(stderr, "Tpinit failed\n");
exit(1);
}

if((sendbuf = (FBFR32 *) tpalloc("FML32", NULL, 0)) == NULL) {


fprintf(stderr,"Error allocating send buffer\n");
tpterm();
exit(1);
}

if((recvbuf = (FBFR32 *) tpalloc("FML32", NULL, 0)) == NULL) {


fprintf(stderr,"Error allocating receive buffer\n");
tpfree((char *)sendbuf);
tpterm();
exit(1);
}

tmpbuf = malloc(sizeof(struct temp_str));

printf("\n******************************************\n");

68 Tibero Application Developer's Guide


printf( "| Employee Number : " ); scanf ( "%d", &tmpbuf->empno );
printf( "| Employee Name : " ); scanf ( "%s", tmpbuf->ename );
printf( "| Employee Job : " ); scanf ( "%s", tmpbuf->job );
printf("******************************************\n\n");

tpbegin(10, 0);
Fchg32(sendbuf,EMPNO,0,(char *)&tmpbuf->empno,0);
Fchg32(sendbuf,ENAME,0,(char *)tmpbuf->ename,0);
Fchg32(sendbuf,JOB,0,(char *)tmpbuf->job,0);

ret = tpcall("INSERT_FML32", (char *)sendbuf, 0, (char **)&recvbuf,


&recvlen, (long)0);
if(ret == -1) {
fprintf(stderr, "tperrno = %d (%s) \n", tperrno, tpstrerror(tperrno));
tpfree((char *)sendbuf);
tpfree((char *)recvbuf);
tpterm();
exit(1);
}

flen = sizeof( msgbuf );


Fget32(recvbuf, OUTPUT, 0, (char *)msgbuf, &flen);
printf("%s\n", msgbuf);

tpcommit(0);

free(tmpbuf);
tpfree((char *)sendbuf);
tpterm();
}

B.7. select.c
The following is a client program file, SELECT.

#include <stdio.h>
#include <atmi.h>
#include <fml32.h>
#include <string.h>
#include "fml32.fld.h"

main(argc, argv)
char *argv[];
{
FBFR32 *sendbuf;

Appendix B. Example of Integrating Tibero with


Tuxedo 69
FBFR32 *recvbuf;
long recvlen;
int ret;
int empno;
FLDLEN32 flen;
int h_empno;
char h_ename[10];
char h_job[10];
char msgbuf[256];

if (tpinit((TPINIT *) NULL) == -1) {


fprintf(stderr, "Tpinit failed\n");
exit(1);
}

if((sendbuf = (FBFR32 *) tpalloc("FML32", NULL, 0)) == NULL) {


fprintf(stderr,"Error allocating send buffer\n");
tpterm();
exit(1);
}

if((recvbuf = (FBFR32 *) tpalloc("FML32", NULL, 0)) == NULL) {


fprintf(stderr,"Error allocating receive buffer\n");
tpfree((char *)sendbuf);
tpterm();
exit(1);
}

printf("\n******************************************\n");
printf( "| Employee Number : " ); scanf ( "%d", &empno );
printf("******************************************\n\n");

Fchg32(sendbuf,EMPNO,0,(char *)&empno,0);

ret = tpcall("SELECT_FML32", (char *)sendbuf, 0, (char **)&recvbuf,


&recvlen, (long)0);
if(ret == -1) {
fprintf(stderr, "tperrno = %d (%s)\n", tperrno, tpstrerror(tperrno));
flen = sizeof( msgbuf );
Fget32(recvbuf, OUTPUT, 0, (char *)msgbuf, &flen);
printf("error msg: %s\n", msgbuf);
tpfree((char *)sendbuf);
tpfree((char *)recvbuf);
tpterm();
exit(1);
}

70 Tibero Application Developer's Guide


flen = sizeof(msgbuf);
Fget32(recvbuf, OUTPUT, 0, (char *)msgbuf, &flen);
printf("%s\n", msgbuf);

flen = sizeof(&h_empno);
Fget32(recvbuf, EMPNO, 0, (char *)&h_empno, &flen);
printf("EMPNO; %d \n", h_empno);
flen = sizeof(h_ename);
Fget32(recvbuf, ENAME, 0, (char *)h_ename, &flen);
printf("ENAME: %s \n", h_ename);
flen = sizeof(h_job);
Fget32(recvbuf, JOB, 0, (char *)h_job, &flen);
printf("JOB: %s \n", h_job);

tpfree((char *)recvbuf);
tpfree((char *)sendbuf);
tpterm();
}
~

B.8. buildc.sh
The following is a client program's build script.

buildclient -o insert -v -f insert.c


buildclient -o select -v -f select.c

B.9. create_table.sql
The following is a file for creating a DB table.

drop table emp;


CREATE TABLE emp (
empno NUMBER,
ename VARCHAR2(10),
job VARCHAR2(9),
mgr NUMBER(4),
hiredate DATE,
sal NUMBER(7,2),
comm NUMBER(7,2),
deptno NUMBER(2)
);
~

Appendix B. Example of Integrating Tibero with


Tuxedo 71
B.10. run.sh
The following is a script for starting the Tuxedo system.

#!/bin/sh

tmshutdown -y
rm ULOG* > /dev/null 2>&1
rm xa* > /dev/null 2>&1

tmloadcf -y tb_tux.conf.m
rm /data1/apmqam/tibero_tuxedo_test/TLOG* > /dev/null 2>&1
rm /data1/apmqam/tibero_tuxedo_test/ULOG* > /dev/null 2>&1

tmadmin -c << EOF


crdl -z /data1/apmqam/tibero_tuxedo_test/TLOG -b 1000
q
EOF

tmboot -y

72 Tibero Application Developer's Guide


G
Index getConnection, 18
getInt(bind_no), 21
getString(result_no), 19

I
B in-doubt transaction, 29
binary type, 1 interface method, 10
BLOB, 7 INTERVAL DAY TO SECOND, 6
INTERVAL YEAR TO MONTH, 5
C
call, 20 J
callable statement, 20 JDBC standard features, 10
CHAR, 2 JDK, 9
CLOB, 3
close, 18, 22 L
commit phase, 28
LONG, 3
commitment, 21
LONG RAW, 7
connection, 17
connection pooling, 13
M
createStatement, 19
mod_tbPSM, 55
multithreading, 11
D
data type, 1
N
data type list, 1
NCHAR, 2
DATE, 4
NCLOB, 3
Datetime type, 1
NUMBER, 4
distributed transaction, 27
Number type, 1
DPV_2PC_PENDING, 30
NVARCHAR, 3

E
P
embedded type, 1
ParameterMetaData, 13
executeQuery, 19
prepare phase, 28
executeUpdate, 21
prepareCall(str), 21
executeUpdate(query_str), 21
prepareStatement, 19
executeUpdate(str), 19
execution, 18
R
F RAW, 6
registerOutParameter(bind_no, type), 21
first phase, 28
ResultSet, 19
rollback, 21

Index 73
ROWID, 7

S
savepoint, 14
scalar functions, 11
second phase, 28
setInt, 21
SQL-92, 11
statement, 18
string type, 1

T
tbJDBC, 9
Tibero XA interface, 35
TIME, 4
TIMESTAMP, 4
TIMESTAMP WITH LOCAL TIME ZONE, 5
TIMESTAMP WITH TIME ZONE, 5
TP-Monitor, 27, 41
Transaction Processing Monitor, 41
trigger, 23
trigger components, 23
trigger type, 24
two-phase commit, 27

U
UDT, 14

V
VARCHAR, 2
VARCHAR2, 2
VT_XA_BRANCH, 30

X
XA, 27
XA function, 30
XA transaction branch, 30
xa_open function properties, 31

74 Tibero Application Developer's Guide

You might also like