Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
32
Добавлен:
16.04.2013
Размер:
4.96 Mб
Скачать

Developing and Installing Applications That Use the XA Libraries

The DBA or system administrator should be aware that a TPM system starts the process that connects to Oracle Database. See your TPM documentation to determine what environment exists for the process and what user ID it will have.

Be sure that correct values are set for ORACLE_HOME and ORACLE_SID.

Next, grant the user ID write permission to the directory in which the XA trace file will be written.

See Also: "Defining the xa_open String" on page 16-9 for information on how to specify a sid or a trace directory that is different from the defaults

Also be sure to grant the user the SELECT privilege on DBA_PENDING_

TRANSACTIONS.

4.Start up the relevant databases to bring Oracle XA applications on-line. This should be done before starting any TPM servers.

Responsibilities of the Application Developer

The responsibilities of the application developer are:

1.Define the open string with help from the DBA or system administrator. Defining the open string is described later in this section.

2.Develop the applications.

Observe special restrictions on transaction-oriented SQL statements for precompilers.

See Also: "Interfacing XA with Precompilers and OCIs" on page 16-16

3.Link the application according to TPM vendor instructions.

Defining the xa_open String

The open string is used by the transaction monitor to open the database. The maximum number of characters in an open string is 256.

This section covers:

Using Oracle XA with Transaction Monitors 16-9

Developing and Installing Applications That Use the XA Libraries

Syntax of the xa_open String

Required Fields

Optional Fields

Syntax of the xa_open String

Oracle_XA{+required_fields...} [+optional_fields...]

where required_fields is a set of any of the following:

Acc=P//

Acc=P/user/password

SesTm=session_time_limit

and where optional_fields is a set of any of the following:

NoLocal=true | false

RAC_FAILOVER=true | false

DB=db_name

LogDir=log_dir

MaxCur=maximum_#_of_open_cursors

Objects=true | false

SqlNet=connect_string

Loose_Coupling=true | false

SesWt=session_wait_limit

Threads=true | false

Note:

You can enter the required fields and optional fields in any order when constructing the open string.

All field names are case insensitive. Their values may or may not be case-sensitive depending on the platform.

There is no way to use the plus character (+) as part of the actual information string.

16-10 Oracle Database Application Developer's Guide - Fundamentals

Developing and Installing Applications That Use the XA Libraries

Required Fields

Required fields for the open string are described in this section.

Acc=P//

or

Acc=P/user/password

Syntax Element

Description

 

 

Acc

Specifies user access information

P

Indicates that explicit user and password information is

 

provided.

P//

Indicates that no explicit user or password information is

 

provided, and that the operating system authentication form

 

will be used.

 

For more information see Oracle Database Administrator's Guide.

user

A valid Oracle Database account.

password

The corresponding current password.

 

 

For example, Acc=P/scott/tiger indicates that user and password information is provided. In this case, the user is scott and the password is tiger.

As previously mentioned, make sure that scott has the SELECT privilege on the

DBA_PENDING_TRANSACTIONS table.

Acc=P// indicates that no user or password information is provided, thus defaulting to operating system authentication.

SesTm=session_time_limit

Syntax Element

Description

 

 

SesTm

Specifies the maximum length of time a transaction can be

 

inactive before it is automatically aborted by the system.

Using Oracle XA with Transaction Monitors 16-11

Developing and Installing Applications That Use the XA Libraries

Syntax Element

Description

session_time_limit This value should be the maximum time allowed in a transaction between one service and the next, or a service and the commit or rollback of the transaction.

For example, if the TPM uses remote procedure calls between the client and the servers, then SesTM applies to the time between the completion of one RPC and the initiation of the next RPC, or the tx_commit, or the tx_rollback.

The unit for this time limit is in seconds. The value of 0 indicates no limit. For example, SesTM=15 indicates that the session idle time limit is 15 seconds.

Entering a value of 0 is strongly discouraged. It might tie up resources for a long time if something goes wrong. Also, if a child process has SesTM=0, the SesTM setting is not effective after the parent process is terminated.

Optional Fields

This section describes optional fields.

NoLocal=true | false

Syntax Element

Description

NoLocal

true | false

Specifies whether local transactions are allowed. The default value is false.

If the application needs to disallow local transactions, then set the value to true.

RAC_FAILOVER=true | false

Syntax Element

Description

 

 

RAC_FAILOVER

Specifies whether XA_RECOVER waits until instance recovery

 

finishes. The default value is false (no wait).

true | false

To force XA_RECOVER to wait until SMON finishes cache

 

recovery, identifies in-doubt transactions, and adds them to the

 

table DBA_2PC_PENDING, set the value to true.

 

 

16-12 Oracle Database Application Developer's Guide - Fundamentals

Developing and Installing Applications That Use the XA Libraries

DB=db_name

Syntax Element

Description

DB

db_name

Specifies the database name.

Indicates the name used by Oracle Database precompilers to identify the database.

Application programs that use only the default database for the Oracle Database precompiler (that is, they do not use the AT clause in their SQL statements) should omit the DB=db_name clause in the open string.

Applications that use explicitly named databases should indicate that database name in their DB=db_name field.

Version 7 OCI programs need to call the sqlld2() function to obtain the correct lda_def, which is the equivalent of a service context. Version 8 OCI programs need to call the xaoSvcCtx function to get the OCISvcCtx service context.

The db_name is not the sid and is not used to locate the database to be opened. Rather, it correlates the database opened by this open string with the name used in the application program to execute SQL statements. The sid is set from either the environment variable ORACLE_SID of the TPM application server or the sid given in the Oracle Net clause in the open string. The Oracle Net clause is described later in this section. (Oracle Net was formerly known as SQL*Net and Net8.)

Some TPM vendors provide a way to name a group of servers that use the same open string. The DBA may find it convenient to choose the same name both for that purpose and for db_ name.

For example, DB=payroll indicates that the database name is "payroll", and that the application server program will use that name in AT clauses.

LogDir=log_dir

Syntax Element

Description

LogDir

log_dir

Specifies the directory on a local machine where the Oracle XA library error and tracing information may be logged.

Indicates the path name of the directory where the tracing information should be stored. The default is $ORACLE_ HOME/rdbms/log if ORACLE_HOME is set; otherwise, it is the current directory.

Using Oracle XA with Transaction Monitors 16-13

Developing and Installing Applications That Use the XA Libraries

For example, LogDir=/xa_trace indicates that the error and tracing information is located under the /xa_trace directory.

Note: Ensure that the directory you specify for logging exists and the application server can write to it.

Loose_Coupling=true | false

See Also: "Transaction Branches" on page 16-30 for a complete explanation

Objects=true | false

Syntax Element

Description

Objects

true | false

Specifies whether the application is initialized in object mode. The default value is false.

If the application needs to use certain API calls that require object mode, such as OCIAssignRawbytes(), then set the value to true.

MaxCur=maximum_#_of_open_cursors

Syntax Element

Description

 

 

MaxCur

Specifies the number of cursors to be allocated when the

 

database is opened. It serves the same purpose as the

 

precompiler option maxopencursors.

maximum_#_of_open_cursors Indicates the number of open cursors to be cached.

For example, MaxCur=5 indicates that the precompiler should try to keep five open cursors cached.

Note: This parameter overrides the precompiler option maxopencursors that you might have specified in your source code or at compile time.

See Also: Pro*C/C++ Programmer's Guide

16-14 Oracle Database Application Developer's Guide - Fundamentals

 

 

Developing and Installing Applications That Use the XA Libraries

 

 

 

 

SqlNet=db_link

 

 

 

 

 

Syntax Element

Description

 

 

 

 

SqlNet

Specifies the Oracle Net database link. (Oracle Net was formerly

 

 

known as SQL*Net and Net8.)

 

db_link

Indicates the string to use to log on to the system. The syntax for

 

 

this string is the same as that used to set the TWO-TASK

 

 

environment variable.

 

 

 

For example, SqlNet=hqfin@NEWDB indicates the database with sid NEWDB accessed at host hqfin by TCP/IP.

The SqlNet parameter can be used to specify the ORACLE_SID in cases where you cannot control the server environment variable. It must also be used when the server needs to access more than one Oracle Database instance. To use the Oracle Net string without actually accessing a remote database, use the Pipe driver.

For example:

SqlNet=localsid1

localsid1 is an alias defined in the tnsnames.ora file.

Make sure that all databases to be accessed with a Oracle Net database link have an entry in /etc/oratab.

SesWt=session_wait_limit

Syntax Element

Description

 

 

SesWt

Specifies the time-out limit when waiting for a transaction

 

branch that is being used by another session. The default value

 

is 60 seconds.

session_wait_limit The number of seconds Oracle Database waits before XA_RETRY is returned.

Using Oracle XA with Transaction Monitors 16-15

Тут вы можете оставить комментарий к выбранному абзацу или сообщить об ошибке.

Оставленные комментарии видны всем.

Соседние файлы в папке Oracle 10g