Professional Documents
Culture Documents
Tibero v5.0 SP1 Application Developer's Guide v2.1.1 en
Tibero v5.0 SP1 Application Developer's Guide v2.1.1 en
Tibero 5 SP1
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.
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
Edition: 2.1.1
Table of Contents
About This Document ................................................................................................................. ix
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
Index .......................................................................................................................................... 73
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
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."
Describes the data types provided by Tibero and explains their usage.
Chapter 4: Using XA
Describes how to use mod_tbPSM that calls tbPSM procedures and gets HTML pages using Apache
HTTP web server.
Provides the full source code of an example program written using tbJDBC.
Provides the full source code of an example program that integrates Tibero with Tuxedo and relevant
scripts.
Boldface Emphasis
" " (double quotes) Reference to chapters or sections in the manual, or to other related
documentations
Reference or note
Note
{} Required argument
[] Optional argument
| Selective argument
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.
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 troubleshooting methods for all sorts of errors that may occur
while using Tibero .
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
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
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
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
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.
Binary type RAW, BLOB, LONG RAW Large amounts of binary data.
Note
For more information about data types, refer to the "Tibero SQL Reference Guide."
CHAR[(size)]
Option Description
VARCHAR
The VARCHAR type stores variable-length character strings.
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.
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.
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.
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.
CLOB
NCLOB
The NCLOB type stores a large amount of readable strings that use the national character set.
NCLOB
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.
NUMBER
The NUMBER type stores variable-length integers or real numbers.
Option Description
scale Sets the number of digits to the right of the decimal point.
DATE
The DATE type stores fixed-length strings of year, month, and date.
DATE
TIME
The TIME type stores fixed-length strings of hour, minute, and second.
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.
TIMESTAMP[(frac_sec_prec)]
Option Description
Option Description
Option Description
Option Description
Note
This type can limit the number of digits stored for date and fractional second using day_prec and
frac_sec_prec.
RAW
The RAW type stores variable-length binary data.
RAW(size)
Option Description
size The data length is the byte length of the data. (Maximum: 2,000 bytes)
BLOB
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.
LONG RAW
ROWID
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."
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
This section describes the standard features of tbJDBC according to JDBC version. For more information,
refer to Sun Microsystems's JDBC 4.0 Specification.
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.
Interface methods
java.sql.Array
java.sql.Blob
java.sql.CallableStatement
java.sql.Clob
java.sql.Connection
java.sql.DatabaseMetaData
java.sql.Driver
java.sql.ResultSet
java.sql.ResultSetMetaData
java.sql.Statement
java.sql.Struct
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.
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 record in the current position set by a cursor in a ResultSet can be updated and deleted.
Sensitive ResultSet
RowSet feature
Distributed transactions
Unsupported Features
SQL-99 data types
Of the SQL-99 data types, tbJDBC does not support Array, Ref, or Struct.
Interface methods
java.sql.Ref
java.sql.SQLData
java.sql.SQLInput
java.sql.SQLOutput
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.
Supported Features
Interface
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
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
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
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.
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.
The searching and modifying of an object referred by a REF object are not supported.
User defined data types (UDTs) and java classes can be mapped with the JDBC API. However, Tibero
does not support UDT.
java.sql.NClob
java.sql.RowId
java.sql.SQLXML
java.sql.Wrapper
javax.sql.StatementEventListener
The usage of a driver object, without loading the java.sql.Driver class by using Class.forName method,
is supported.
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.
The API for creating and releasing a BLOB or CLOB object is supported.
The usage of the SQL ROWID type using the rowid interface is supported.
Accessing an actual JDBC object with the wrapper interface is supported in an application server or 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.
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:
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;
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.
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!");
}
The com.tmax.tibero.jdbc.TbDriver class is loaded, which registers the default driver that will be used
by the user.
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.
try {
stmt.executeUpdate(dropTable);
} catch(SQLException e) {
// if there is not the table
}
stmt.executeUpdate(createTable);
stmt.executeUpdate(InsertTable);
stmt.close();
}
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.
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.
pstmt.setString(1, "1000");
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
System.out.println(rs.getString(1));
}
pstmt.close();
}
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.
The executeCallableStatement member function (labeled <D> in [Example 2.1]) executes callable
statements.
try {
stmt.executeUpdate(dropProc);
} catch(SQLException e) {
// if there is not the procedure
}
stmt.executeUpdate(callSQL);
stmt.close();
cstmt.close();
}
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.
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.
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.
If the conn object exists, connections to the database can be released using the close member function.
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.
Actions to be performed
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.
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.
Type Description
A trigger type can be one of the following: BEFORE row, BEFORE statement, AFTER row, and AFTER
statement.
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.
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.
This chapter explains XA (Extended Architecture) used for handling distributed transactions.
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."
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:
The two-phase commit mechanism is performed in two phases. The figure above is described as follows:
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.
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.
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.
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.
Function Description
xa_start Starts a new transaction with a given global transaction identifier (XID) or
associates current process with an existing transaction.
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.
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.
/* 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], >rid, 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], >rid, sizeof(gtrid));
memcpy(&xid2.data[sizeof(gtrid)], &bqual,
sizeof(bqual));
/* (1, 1) */
/* xa_start -- sql statements starts */
/* 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;
}
Chapter 4. Using XA 33
char *conn_str = XA_CONN_STR_LOOSE;
long gtrid = _GTRID_BASE;
long bqual = 1;
/* 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], >rid, 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], >rid, sizeof(gtrid));
memcpy(&xid2.data[sizeof(gtrid)], &bqual,
sizeof(bqual));
/* (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);
/* 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
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
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.*;
create_table_for_xa();
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) {}
while (rs1.next())
row_count ++;
assertEquals(4, row_count);
xads1.setUrl(getXAurl());
xads1.setUser(getXAuser());
xads1.setPassword(getXApasswd());
xads2.setUrl(getXAurl());
xads2.setUser(getXAuser());
xads2.setPassword(getXApasswd());
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);
while (rs1.next())
row_count ++;
assertEquals(4, row_count);
This section describes Tmax and Tuxedo, which are superior commercial TP-monitors, and example
programs that integrate them with Tibero.
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
Chapter 4. Using XA 41
Classification Description
Shell bash
Files
File Description
1. Configuring Tmax
2. Compiling TMS
5. Creating a DB table
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.
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."
cfl -i sample.m
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
cd $TMAXDIR/sample/server
./compile tbc tbrtest
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
tmboot
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]]
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
OS AIX
Shell bash
Files
File Description
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.
2. Configuring Tuxedo
3. Compiling TMS
Chapter 4. Using XA 47
5. Compiling client programs
6. Creating a DB table
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
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
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
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.
tmloadcf -y tb_tux.conf.m
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.
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:
Note
Creating a DB table
Access Tibero server using the tibero/tmax account to create the emp table as follows:
tbsqltibero/tmax
Chapter 4. Using XA 51
sal NUMBER(7,2),
comm NUMBER(7,2),
deptno NUMBER(2)
);
tmboot -y
exec BBL -A :
process id=3457104 ... Started.
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.
Execute a client program to add employee information to the emp table as follows:
./insert
******************************************
| Employee Number : 1
| Employee Name : Kim
| Employee Job : Manager
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.
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.
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:
[Reference]
When specifying a path, use a back slash (\) for Windows and a slash (/) for Apache.
The Location segment in the Apache configuration file should be identical as the previous example.
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."
HTP.HEADOPEN;
HTP.TITLE(title);
HTP.HEADCLOSE;
HTP.BODYOPEN;
HTP.PRINT(text);
HTP.BODYCLOSE;
HTP.HTMLCLOSE;
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.
http://{http_server_ip}:{http_server_port}/tbpsm/{tibero_dsn}/
{package_name}.{procedure_name}?{parameter1}={value1}&{parameter2}={value2)&...
Item Description
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.
parameter1, parameter2, ... , Parameter names of a procedure. In the URL address format, these
parametern items are query parameters.
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:
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.
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;
test.connect();
test.executeStatement();
test.executePreparedStatement();
test.executeCallableStatement();
test.disconnect();
}
conn = DriverManager.getConnection(
"jdbc:tibero:thin:@localhost:6666:tibero",
"tibero", "tmax");
if (conn == null)
{
try {
stmt.executeUpdate(dropTable);
} catch(SQLException e) {
// if there is not the table
}
stmt.executeUpdate(createTable);
stmt.executeUpdate(InsertTable);
stmt.close();
}
pstmt.setString(1, "1000");
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
System.out.println(rs.getString(1));
}
pstmt.close();
}
try {
stmt.executeUpdate(dropProc);
} catch(SQLException e) {
// if there is not the procedure
}
stmt.executeUpdate(callSQL);
stmt.close();
cstmt.close();
}
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.
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"
*SERVICES
SELECT_FML32
INSERT_FML32
B.3. tmax32.fld
The following is a field table file.
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"
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;
tx_info(&info);
xid = &(info.xid);
Fprint32(sndbuf);
memset( &h_empno, 0x00, sizeof ( h_empno ) );
memset( h_ename, 0x00, sizeof ( h_ename ) );
memset( h_job, 0x00, sizeof ( 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);
}
void SELECT_FML32(rqst)
TPSVCINFO *rqst;
{
FBFR32 *sndbuf;
char msgbuf[256];
FLDLEN32 flen;
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);
}
Fprint32(sndbuf);
tpreturn(TPSUCCESS, 0,(char *)sndbuf, sizeof(sndbuf), 0);
}
B.5. builds.sh
The following is a server program's build script.
B.6. insert.c
The following is a client program file, INSERT.
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;
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);
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;
printf("\n******************************************\n");
printf( "| Employee Number : " ); scanf ( "%d", &empno );
printf("******************************************\n\n");
Fchg32(sendbuf,EMPNO,0,(char *)&empno,0);
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.
B.9. create_table.sql
The following is a file for creating a DB table.
#!/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
tmboot -y
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