uCosminexus Service Platform, Reception and Adapter Definition Guide

[Contents][Glossary][Index][Back][Next]

3.3.5 Defining Database Adapters

This subsection describes how to define DB adapters.

Organization of this subsection
(1) Creating the SQL operation definition file
(2) Creating a message format
(3) Operations in the Service Adapter Settings window
(4) Editing the HITACHI Application Integrated Property File
(5) Data transformation
(6) Replacing the EAR file
(7) Creating a service requester

(1) Creating the SQL operation definition file

The SQL operation definition file defines information about the database accessed via the DB adapter in the execution environment and the SQL execution format. This file is used as the base when creating an XML format definition file for a DB adapter.

The following describes how to create the SQL operation definition file.

Create the SQL operation definition file in the XML document format by using a program such as a text editor. If you use any characters that cannot be used for XML documents (such as <, >, or &), you need to escape such characters or use the CDATA section.

Specify elements, attributes, and text data that conform to the W3C XML specifications.

You cannot use the XML name space.

The following shows details of the XML document to be created here.

[Figure] File name
Specify the name of the SQL operation definition file in the following format:
 
csa_sql_any-name.xml
 

[Figure] Structure
The following figure shows the structure of the SQL operation definition file.

Figure 3-2 Structure of the SQL operation definition file

[Figure]

[Figure]Format of the SQL operation definition file
The format of the SQL operation definition file is shown below. The italic characters indicate variable values.
 
<?xml version="XML-version" encoding="character-encoding"?>
<DBadapter_SQL_OPERATION dba_separate_transaction="transaction-separate-option">
    <DATABASE_DATA>
        <DB_NAME dynamic="connection-target-dynamic-change-option">database-reference-name</DB_NAME>
        <DB_TYPE>database-type</DB_TYPE>
    </DATABASE_DATA>
    <SQL_DATA encoding="encoding-and-decoding-format-of-character-binary-data">
        <SQL-identifier out_maxOccurs="maximum-number-of-output-search-results">
            SQL-instruction <argument-element-name dba_inf="argument-type" data_type="data-format"/>
        </SQL-identifier>
            :
    </SQL_DATA>
    <MULTI_SQL_DATA>
        <MAX_SQL_NO>maximum-number-of-SQL-statements-that-are-executed-by-one-service-component-request</MAX_SQL_NO>
    </MULTI_SQL_DATA>
</DBadapter_SQL_OPERATION>
 
The following shows the definitions in an SQL operation definition file.
XML declaration
Specify an XML version that conforms to the XML language specifications. Specify UTF-8 for the character encoding. You can omit specifying the character encoding. If you omit specifying the character encoding, UTF-8 or UTF-16 is used.
 
<?xml version="XML-version" encoding="character-encoding"?>
 
Root element (element name: DBadapter_SQL_OPERATION)
The root element of the SQL operation definition file.
 
<DBadapter_SQL_OPERATION dba_separate_transaction="Y|N">
    :
</DBadapter_SQL_OPERATION>
 
  • dba_separate_transaction
    Specify whether to start the transaction for the DB adapter separately from the business process. Specify Y if you want to separate transactions, or N if you do not want to separate transactions. If you omit this specification, the value of dba-separate-transaction in the HCSC server runtime definition file will be valid. The value specified for this attribute takes preference over the value of dba-separate-transaction in the HCSC server runtime definition file.
    Before specifying Y for this attribute, change the value for the trans-attribute element in the HITACHI Application Integrated Property File of the DB adapter from Required to RequiresNew.
Database information (element name: DATABASE_DATA)
Specify the database information in the lower elements (DB_NAME and DB_TYPE).
 
<DATABASE_DATA>
    database-reference-name
    database-type
</DATABASE_DATA>
 
Database reference name (element name: DB_NAME)
Specify the database reference name of DB Connector.
Specify the same value as for the res-ref-name element in the HITACHI Application Integrated Property File in order to search for the resource reference in that file when the DB adapter is executed, based on the value specified here.
If Y is set for the dynamic attribute, you can omit specifying the value for this element, and the value already set for this element is ignored.
 
<DB_NAME dynamic="Y|N">database-reference-name</DB_NAME>
 
  • dynamic
    Specify whether to dynamically change the connection target.
    Specify Y if you want to dynamically change the connection target, or N if you do not want to dynamically change the connection target. If you omit specifying the value, N is assumed.
Database type (element name: DB_TYPE)
Specify one of the following as the database type:
  • HIRDB
    Specify this option if you want to use HiRDB as the DBMS (if DBConnector_DABJ_CP/XA.rar is used as the DB Connector).
  • HIRDB-TYPE4
    Specify this option if you want to use HiRDB as the DBMS (if DBConnector_HiRDB_Type4_CP/XA.rar is used as the DB Connector).
  • ORACLE
    Specify this option if you want to use Oracle as the DBMS (if DBConnector_DABJ_CP/XA.rar is used as the DB Connector).
  • ORACLE-THIN
    Specify this option if you want to use Oracle as the DBMS (if DBConnector_Oracle_CP/XA.rar is used as the DB Connector).
     
    <DB_TYPE>database-type</DB_TYPE>
     
SQL information (element name: SQL_DATA)
In the lower elements (SQL-identifier and SQL-statement), specify the SQL information to be executed.
 
<SQL_DATA encoding="hexBinary|base64Binary">
    SQL-identifier
        SQL-statement
</SQL_DATA>
 
  • encoding
    Specify the encoding and decoding format of binary data.
    Specify hexBinary to encode or decode in hexBinary format, or base64Binary to encode or decode in base64Binary format. If you omit specifying this value, hexBinary is assumed.
    This attribute is valid only when the following data formats are specified for the data_type attribute:
    - For HiRDB: LONGVARBINARY
    - For Oracle: VARBINARY, LONGVARBINARY, BLOB
    Note
    When you perform data transformation for binary data, specify the same value for the encoding attribute in the SQL operation definition file and the encoding or decoding format in the binary format definition file. If different formats are specified, correct operations are not guaranteed.
    Reference note
    To change the encoding or decoding format to base64binary when the DB adapter is upgraded in an environment where a version earlier than 09-50 is used:
    1. Re-create the binary format definition file in the development environment.
    2. Modify the SQL operation definition file (set the encoding or decoding format).
    3. Execute the csamkxmls command to create the XML schema by using the modified SQL operation definition file.
    4. Set the XML schema and the binary format definition file to the DB adapter in the development environment.
    5. Set the mapping definition again in the development environment.
    6. Set the SQL operation definition file modified in the development environment to the DB adapter.
    7. Deploy the DB adapter again.
SQL identifier (element name: any (1 to 256 characters))
This element identifies the SQL to be executed. If you omit specifying this element, the SQL statement is not executed. In the lower argument element, specify the SQL statement. You can specify out_maxOccurs as the attribute. You can also specify the SQL identifier multiple times (the number is equal to the number of SQL instructions to be executed).
You cannot specify DBadapter or DBA_MULTI_SQL as the name of the SQL identifier.
 
<SQL-identifier out_maxOccurs="maximum-number-of-output-search-results">
    SQL-statement
</SQL-identifier>
    :
 
  • out_maxOccurs
    Specify the maximum number of output search results. If you omit specifying this value, 1000 is set. If you specify 0, 2147483647 is set.
SQL statement
Specify the SQL statement. The syntax of the SQL statement must conform to the specifications of the database to be used. Specify the variable parts (argument elements), such as the table and column names and data in the SQL statement.
You do not have to add a semicolon (;) to indicate the end of the SQL statement.
 
SQL-instruction <argument-element-name dba_inf="argument-type" data_type="data-format"/>
 
For the beginning of the SQL statement, specify SELECT[Figure] or INSERT[Figure] ([Figure] indicates a single-byte space). If an argument element follows immediately after SELECT[Figure] or INSERT[Figure], you can omit [Figure] (single-byte space).
The following describes the specified information.
SQL instruction
You can specify SELECT or INSERT as the SQL instruction.
The following table lists and describes the data types that can be searched for by using SELECT.

Table 3-3 Data types that can be searched for by using SELECT (for HiRDB)

HiRDB data type Searchable
For HiRDB Type4 JDBC Driver
INT [EGER] Y
SMALLINT Y
[LARGE] DEC [IMAL]
NUMERIC
Y
FLOAT
DOUBLE PRECISION
Y
SMALLFLT
REAL
Y
CHAR [ACTER] Y
VARCHAR
CHAR [ACTER] VARYING
Y
NCHAR
NATIONAL CHAR
Y
NVARCHAR
NATIONAL CHAR [ACTER] VARYING
NCHAR VARYING
Y
MCHAR Y
MVARCHAR Y
DATE Y
TIME Y
TIMESTAMP Y
INTERVAL YEAR TO DAY --
INTERVAL HOUR TO SECOND --
BLOB
BINARY LARGE OBJECT
Y
BINARY Y
BOOLEAN --

Legend:
Y: Can be searched for by using SELECT.
--: Cannot be searched for by using SELECT.

#
You can omit the parts enclosed in square brackets ([]).

Table 3-4 Data types that can be searched for by using SELECT (for Oracle)

Oracle data type Searchable
For Oracle JDBC Thin Driver
VARCHAR2 Y
NVARCHAR2 Y
NUMBER Y
LONG Y
DATE Y#1
BINARY_FLOAT#2 --
BINARY_DOUBLE#2 --
TIMESTAMP --
TIMESTAMP WITH TIME ZONE --
TIMESTAMP WITH LOCAL TIME ZONE --
INTERVAL YEAR TO MONTH --
INTERVAL DAY TO SECOND --
RAW Y
LONG RAW Y
ROWID Y
UROWID --
CHAR Y
NCHAR Y
CLOB Y
NCLOB Y
BLOB Y
BFILE --
User-defined type (object type) --
User-defined type (REF data type) --
User-defined type (VARRAY) --
User-defined type (nested table) --

Legend:
Y: Can be searched for by using SELECT.
--: Cannot be searched for by using SELECT.

#1
When you use Oracle JDBC Thin Driver of Oracle 11g or Oracle12c, you need to set the following value as the JVM startup parameter in the definition of the logical J2EE server:
-Doracle.jdbc.mapDateToTimestamp=false
For details about how to set the startup parameter, see the Application Server Management Portal Operation Guide.

#2
This data type can be used only when the connection-target database is Oracle 11g.

[Figure] Point
You can use a function provided by the database to convert an unsearchable data type to one that can be searched.
In the following example, the TO_CHAR function is used to convert the TIMESTAMP type (column name: c_ts) of Oracle to the VARCHAR2 type for searching.
 
SELECT TO_CHAR(c_ts) FROM table-name
 
Argument element name
Specify an argument element name. If the same name is specified for multiple argument elements, the arguments are treated as the same argument. If two or more argument elements have the same name, but have different values for the dba_inf and data_type attributes, an error occurs.
dba_inf="argument-type"
Specify the argument type.
The following describes what can be specified for the argument types.
  • table
    Specify this when the argument is the name of a table that exists in the database. String-type data is used for the argument.
  • column
    Specify this when the argument is the name of a column that exists in the database. String-type data is used for the argument.
  • data
    Specify this when the argument is data other than the name of a table or column. If you specify this value, specify for the data_type attribute the type of data to be used for the argument. Also, convert the data to be used for the argument to the Java data type or class shown in Table 3-3 and Table 3-4, and then add it to the SQL statement. If the data to be used for the argument cannot be converted, an error occurs.
    Note that, when you specify this value, the argument element is treated as the IN parameter (? parameter or bind variable). In the SQL statement, you can specify the IN parameter at the location defined in the specifications of the database to be used. If you define the IN parameter at a location that is not allowed by the specifications, an error occurs. The argument element is replaced with ? and then executed when SQL is executed.
  • preset
    Specify this when the argument is data other than the name of a table or column. When you specify this value, insert the data to be used for the argument into the SQL statement as is. String-type data is used for the argument.
data_type="data-type"
When you specify data for the dba_inf attribute, specify the type of data to be used for the argument. The following table shows the correspondence between the data types of the database and the data types that can be specified for data_type.

Table 3-5 Data types that can be specified for data_type (for HiRDB)

HiRDB data type Data type that can be specified for data_type Data type and class that the data to be used for the argument is converted to
INT [EGER] INTEGER int
SMALLINT SMALLINT short
[LARGE] DEC [IMAL]
NUMERIC
DECIMAL java.math.BigDecimal
FLOAT
DOUBLE PRECISION
FLOAT double
SMALLFLT
REAL
REAL float
CHAR [ACTER] CHAR java.lang.String
NCHAR
NATIONAL CHAR
MCHAR
VARCHAR
CHAR [ACTER] VARYING
VARCHAR java.lang.String
NVARCHAR
NATIONAL CHAR [ACTER] VARYING
NCHAR VARYING
MVARCHAR
DATE DATE java.sql.Date
TIME TIME java.sql.Time
TIMESTAMP TIMESTAMP java.sql.Timestamp
BLOB
BINARY LARGE OBJECT
LONGVARBINARY byte[]
BINARY LONGVARBINARY byte[]

Note:
You can omit the parts enclosed in square brackets ([]).

Table 3-6 Data types that can be specified for data_type (for Oracle)

Oracle data type Data type that can be specified for data_type Data type and class that the data to be used for the argument is converted to
LONG LONGVARCHAR java.io.Reader
NUMBER NUMERIC java.math.BigDecimal
VARCHAR2 VARCHAR java.lang.String
NVARCHAR2 --
ROWID CHAR
CHAR CHAR
NCHAR --
CLOB CLOB#1
  • For Oracle JDBC Thin Driver
    java.io.Reader
NCLOB --
DATE DATE#2 java.sql.Date
TIME#3 java.sql.Time
TIMESTAMP#4 java.sql.Timestamp
RAW VARBINARY byte[]
LONG RAW LONGVARBINARY byte[]
BLOB BLOB byte[]

Legend:
--: This data type cannot be specified.

#1
This data type can be specified only when the JDBC driver is version 10.2. If a JDBC driver whose version is other than 10.2 is used, the data might be corrupted.

#2
Specify this data type when the format of the setting value is yyyy-mm-dd.

#3
Specify this data type when the format of the setting value is hh.mm.ss.

#4
Specify this data type when the format of the setting value is yyyy-mm-dd hh.mm.ss.

Execution information of multiple SQL statements (element name: MULTI_SQL_DATA)
When executing multiple SQL statements in response to one service component execution request from a service requester, specify the maximum number of SQL statements to be executed in the lower element (MAX_SQL_NO). You can omit specifying this element if you are executing a single SQL statement.
 
<MULTI_SQL_DATA>
    maximum-number-of-SQL-statements-to-be-executed
</MULTI_SQL_DATA>
 

Maximum number of SQL statements to be executed (element name: MAX_SQL_NO)
Specify the maximum number of SQL statements to be executed (maximum number of DBA_MULTI_SQL elements in the request message from the service requester) in the range 1 to 2,147,483,647. If you omit specifying the value, 1024 is set.
 
<MAX_SQL_NO>maximum-number-of-SQL-statements-that-are-executed-by-one-service-component-execution-request</MAX_SQL_NO>
 

[Figure] Example of creating the SQL operation definition file
The following is an example of creating the SQL operation definition file.

Example conditions
Database reference name: DB_SERVER1
Schema name: DBA
Table name: ORDER_TABLE
Table structure:
Order number
(INTEGER)
Customer code (CHAR) Product code
(CHAR)
Number of orders
(INTEGER)
1 AA001 0001 5
2 AB002 0001 1
3 AA001 0102 3
4 XA005 0103 1
5 AA001 0105 1
SQL format to be executed:
 
OPERATION1:SELECT * FROM DBA.ORDER_TABLE WHERE <val1> <val2> <val3>
OPERATION2:SELECT <val1> SUM(<val2>) FROM DBA.ORDER_TABLE GROUP BY <val3>
OPERATION3:INSERT INTO DBA.ORDER_TABLE VALUES(<val1>,<val2>,<val3>,<val4>)
 

Example of creating the SQL operation definition file (when a single SQL statement is executed)
 
<?xml version="1.0" encoding="UTF-8" ?>
<DBadapter_SQL_OPERATION>
    <DATABASE_DATA>
        <DB_NAME>DB_SERVER1</DB_NAME>
        <DB_TYPE>HIRDB</DB_TYPE>
    </DATABASE_DATA>
    <SQL_DATA>
        <OPERATION1>
            SELECT * FROM DBA.ORDER_TABLE WHERE <val1 dba_inf="column"/> 
                <val2 dba_inf="preset"/> 
                <val3 dba_inf="data" data_type="CHAR"/>
        </OPERATION1>
        <OPERATION2>
            SELECT <val1 dba_inf="column"/> SUM(<val2 dba_inf="column"/>) 
                FROM DBA.ORDER_TABLE GROUP BY <val3 dba_inf="column"/>
        </OPERATION2>
        <OPERATION3>
            INSERT INTO DBA.ORDER_TABLE 
                VALUES(<val1 dba_inf="data" data_type="INTEGER" />,
                <val2 dba_inf="data" data_type="CHAR"/>,
                <val3 dba_inf="data" data_type="CHAR"/>,
                <val4 dba_inf="data" data_type="INTEGER"/>)
        </OPERATION3>
    </SQL_DATA>
</DBadapter_SQL_OPERATION>
 
  

Example of creating the SQL operation definition file (when multiple SQL statements are executed)
In the following example, the maximum number of SQL statements to be executed in response to one service component execution request is set to 10.
 
<?xml version="1.0" encoding="UTF-8" ?>
<DBadapter_SQL_OPERATION>
    <DATABASE_DATA>
        <DB_NAME>DB_SERVER1</DB_NAME>
        <DB_TYPE>HIRDB</DB_TYPE>
    </DATABASE_DATA>
    <SQL_DATA>
        <OPERATION1>
            SELECT * FROM DBA.ORDER_TABLE WHERE <val1 dba_inf="column"/> 
                <val2 dba_inf="preset"/> 
                <val3 dba_inf="data" data_type="CHAR"/>
        </OPERATION1>
        <OPERATION2>
            SELECT <val1 dba_inf="column"/> SUM(<val2 dba_inf="column"/>) 
                FROM DBA.ORDER_TABLE GROUP BY <val3 dba_inf="column"/>
        </OPERATION2>
        <OPERATION3>
            INSERT INTO DBA.ORDER_TABLE 
                VALUES(<val1 dba_inf="data" data_type="INTEGER" />,
                <val2 dba_inf="data" data_type="CHAR"/>,
                <val3 dba_inf="data" data_type="CHAR"/>,
                <val4 dba_inf="data" data_type="INTEGER"/>)
        </OPERATION3>
    </SQL_DATA>
    <MULTI_SQL_DATA>
        <MAX_SQL_NO>10</MAX_SQL_NO>
    </MULTI_SQL_DATA>
</DBadapter_SQL_OPERATION>
 

(2) Creating a message format

WSDL is not generated for a DB adapter, so the message format of a service component is also not generated automatically. Therefore, you need to create the message format of the service component (XML format definition file for the DB adapter), and then specify the settings.

(a) Creating the XML format definition file for a DB adapter

To create the XML format definition file for a DB adapter, specify the name of the SQL operation definition file created in (1) Creating the SQL operation definition file for the -o option, and then execute the csamkxmls command.

[Figure] Example of executing the command
The following shows the execution format of the csamkxmls command:
 
installation-directory-of-the-service-platform\CSC\bin\csamkxmls -o name-of-the-SQL-operation-definition-file -x name-of-the-XML-format-definition-file-for-DB-adapter
 
For details about the csamkxmls command, see csamkxmls(Creating XML Format Definition File for Database Adapter) in the manual Service Platform Reference Guide.

Note
When the csamkxmls command is executed, if the SQL operation definition file is too large, the java.lang.OutOfMemoryError message might be displayed.
If this error is displayed, for the HCSCDBA_XMX environment variable, set a value larger than the size currently allocated to the JavaVM memory, and then re-execute the command.
For the HCSCDBA_XMX environment variable, specify the value (unit: Mbyte) set for the JavaVM heap size (-Xmx). If you omit specifying this value, the JavaVM heap size depends on the environment in which the Java command is executed.

Setting example
set HCSCDBA_XMX=64
Note
The XML format definition file for DB adapter contains as many formats as the number of SQL identifiers specified in the SQL operation definition file. If you execute a single SQL statement, you need to change the operation defined for each SQL identifier when defining data transformation (by adding operations in the Service Adapter Settings window). If you execute multiple SQL statements, you do not have to change the operation for each SQL identifier when defining data transformation.
For details about defining data transformation, see Chapter 6. Defining Data Transformation in the manual Service Platform Basic Development Guide. For details about the Service Adapter Settings window, see 1.2.2 Service Adapter Definition Window in the manual Service Platform Reference Guide.
(b) Example of creating an XML format definition file for a DB adapter

The following is an example of creating an XML format definition file for a DB adapter.

Figure 3-3 (Example 1) When using the SELECT statement to use a value in the WHERE clause as an argument

[Figure]

Figure 3-4 (Example 2) When using the SELECT statement to use the column names to be acquired, as arguments

[Figure]

Figure 3-5 (Example 3) When using the SELECT statement to use the column names and expressions in the WHERE clause as arguments

[Figure]

(3) Operations in the Service Adapter Settings window

To define a DB adapter:

  1. Open the Service Adapter Settings window.
    For details about how to open the Service Adapter Settings window, see 3.3.1(4) Displaying the service adapter settings screen.
  2. In Service component control information, edit Service name and Service ID, as necessary.
    Enter the value for Service name when adding the DB adapter if you want to change the entered name.
    The service ID is the identification information that is required when the administrator performs an operation on the HCSC server. We recommend that you specify a value that is related to the service name.
  3. In Service component control information, click the Add button to add an operation.
    The operation name is the identification information that is required when a service requester calls the HCSC server.
  4. If necessary, select the Convert a system exception into a fault message check box in Service component control information.
  5. From the Communication model drop-down list of the operation information, select Sync or Async.
    If you need a response, select Sync.
  6. For the request message, perform steps 7 to 18.
  7. Perform the following operations:
    When specifying the standard message format
    Perform steps 8 to 11, and then go to step 12.
    When not specifying the standard message format
    Go to step 12.
  8. Select the Use check box for the standard message.
  9. Specify the Format ID for the standard message.
    Specify any value for Format ID.
  10. Click the Browse button for the standard message, and specify the standard message format for Message format.
    For details about the forms that can be specified for message formats, see 2.6.5 Scoping of XML schema in the manual Service Platform Basic Development Guide. Note that you cannot specify a message format that refers to an external XML schema.
  11. Click the Display button for the standard message.
    The format of the standard message is displayed. If necessary, check the format of the specified standard message.
  12. Specify the Format ID for the service component message.
    Specify any value for Format ID.
  13. Click the Browse button for the service component message, and specify the service component message format for Message format.
    Here, specify the XML format definition file you created for the DB adapter.
    You can specify only the XML message for Message format.
  14. Click the Display button for the service component message.
    The format of the service component message is displayed. If necessary, check the format of the specified service component message.
  15. If necessary, define a data transformation.
    Perform the following operations:
    When selecting the Use check box for the standard message
    Perform steps 16 to 18, and then go to step 19.
    When not selecting the Use check box for the standard message
    Go to step 19.
  16. Enter the file name for the data transformation definition.
  17. Click the Edit button.
    The Data-conversion definition screen appears.
    Note that, for the first definition, the Select Root Element dialog box appears.
    If you changed the message format, a dialog box appears confirming whether to apply the change on the message format. For details about the procedure when you have changed the message format, see 6.3.2 Procedure for defining changed message formats in the manual Service Platform Basic Development Guide.
  18. Map the contents of the standard message and the contents of the service component message.
  19. If, you selected Sync for Communication model in step 5, also perform steps 7 to 18 for the response message.
  20. Click the Service-adapter definition (details) tab.
  21. Check the name of the service adapter (EJB-JAR file) and self-defined file.
    Ensure that the name of the service adapter (EJB-JAR file) is cscdba_ejb.jar, and the name of the self-defined file is cscadapter_property.xml.
    You do not have to set the utility class (JAR file).
  22. Click the Add button for the self-defined file, and add the following file:
    • SQL operation definition file
      [csa_sql_any-name.xml]

(4) Editing the HITACHI Application Integrated Property File

Use the template file provided by the service platform to edit the HITACHI Application Integrated Property File.

To edit the HITACHI Application Integrated Property File:

  1. In the Service Adapter Settings (details) window, set cscadapter_property.xml for Self-defined file, and then click the Edit button.
    An editor for the HITACHI Application Integrated Property File opens.
  2. In the editor, edit the HITACHI Application Integrated Property File.
    For details about settings properties by using the HITACHI Application Integrated Property File, see 9.2 Property settings using the HITACHI Application Integrated Property File in the manual Application Server Application Setup Guide. For details about the HITACHI Application Integrated Property File, see 3.1 HITACHI Application Integrated Property file in the manual Application Server Application and Resource Definition Reference Guide.
    The following table lists and describes the settings in the HITACHI Application Integrated Property File.

    Table 3-7 Settings in the HITACHI Application Integrated Property File

    Tag Description Setting Can be
    changed
    Setting example
    <hitachi-application-all-property> Root tag -- No --
    <ejb-jar> Opening tag for the definition of information regarding EJB -- No --
    <hitachi-session-bean-property> Opening tag for the definition of the Session Bean attribute -- No --
    <resource-ref> Opening tag for the resource reference#1 definition -- No --
    <res-ref-name> Resource reference name Database reference name specified for the <DB_NAME> tag in the SQL operation definition file Yes DB_SERVER1
    <res-sharing-scope> Specification of whether to share the referenced resource Specification of whether to share the DB Connector referenced by the DB adapter Yes Shareable
    <linked-to> Data source display name Name of the resource adapter specified for the property definition (display-name) of the DB Connector Yes For example, DB_Connector_for_HiRDB_Type4_XA or DB_Connector_for_Oracle_XA#2.
    If you changed display-name, set the new name.
    </resource-ref> Closing tag for the resource reference definition -- No --
    <container-transaction> Opening tag for the definition regarding container transaction -- No --
    <trans-attribute> Transaction attribute assigned to the method Required (inherit the transaction) Yes Required#3
    </container-transaction> Closing tag for the definition regarding container transaction -- No --
    <session-runtime> Opening tag for the definition of runtime -- No --
    <stateless> Opening tag for the definition of stateless -- No --
    <pooled-instance> Opening tag for the definition regarding instances in the pool -- No --
    <minimum> Minimum number of instances in the pool Minimum number of instances in the DB adapter Yes 0 or 1 [Figure] minimum [Figure] maximum
    <maximum> Maximum number of instances in the pool Maximum number of instances in the DB adapter Yes 0 (infinite) or 1 [Figure] maximum [Figure] maximum-sessions
    </pooled-instance> Closing tag for the definition regarding instances in the pool -- No --
    </stateless> Closing tag for the definition of stateless -- No --
    </session-runtime> Closing tag for the definition of runtime -- No --
    </hitachi-session-bean-property> Closing tag for the definition of the Session Bean attribute -- No --
    </ejb-jar> Closing tag for the definition of information regarding EJB -- No --
    </hitachi-application-all-property> Root tag -- No --

    Legend:
    --: The setting for this tag cannot be modified.

    #1
    If Y is set for the dynamic attribute in the SQL operation definition file, omit the definitions of this tag and its child elements.

    #2
    If you changed display-name, specify the new name.

    #3
    To start a transaction for the DB adapter separately from the business process, set true for the dba-separate-transaction property in the HCSC server runtime definition file, or Y for the dba_separate_transaction attribute in the SQL operation definition file. In addition, set RequiresNew for the <trans-attribute> tag in the HITACHI Application Integrated Property File.

    Note
    Do not set or change items other than those that can be set or changed, as shown in Table 3-7.
  3. From the Eclipse menu, select File and then Save to save the definitions.

(5) Data transformation

To perform data transformation of a request message, in the Service Adapter Settings window, set the message to be input from the service requester as the standard message, and in the Data-conversion definition screen, define data transformation. To perform data transformation of a response message, set the standard message for the message returned from the service component, and in the Data-conversion definition screen, define data transformation.

(a) Cases when data transformation is required

If the message format of the service requester is different from the message format of the DB adapter message, data transformation is required.

In the following cases, specify the standard message format to define data transformation:

(b) Defining data transformation

For details about data transformation, see Chapter 6. Defining Data Transformation in the manual Service Platform Basic Development Guide.

(6) Replacing the EAR file

Set the EAR file when adding a DB adapter. If you need to modify the EAR file after adding a DB adapter, in the Service Adapter Settings window of the DB adapter, replace the EAR file.

To replace the EAR file in the Service Adapter Settings window of the DB adapter:

  1. On the Service Definition List in the tree view, double-click the DB adapter for which you replace the EAR file.
    The Service Adapter Settings window appears.
  2. Click the Service-adapter definition (details) tab at the bottom of the window.
    The Service Adapter Settings (details) window appears.
  3. In the Service Adapter Definition (details) window, click the Browse button.
  4. Specify the EAR file to be replaced.

(7) Creating a service requester

How to create a service requester (that issues requests to the DB adapter) depends on the type of standard reception that receives request messages. Create a service requester with reference to the creation method for each type of standard reception. The following table describes the reference destinations.

Table 3-8 How to create a service requester (which issues requests to the DB adapter)

Standard reception type See:
Synchronous reception Web Service (SOAP1.1) See 8.2 Service Requester That Sends Requests to a Standard Synchronous Reception (Web Services) (SOAP communication infrastructure) in the manual Service Platform Basic Development Guide.
Web Service (SOAP1.2) See 8.3 Creating a service requester using standard synchronous reception (Web Services) (JAX-WS engine) in the manual Service Platform Basic Development Guide.
Session Bean See 8.4 Service Requester That Sends Requests to a Standard Synchronous Reception (SessionBean)(JAX-WS engine) in the manual Service Platform Basic Development Guide.
Asynchronous reception MDB (WS-R) See 8.5 Service Requester That Sends Requests to a Standard Asynchronous Reception (MDB (WS-R)) in the manual Service Platform Basic Development Guide.
MDB (DB queue) See 8.6 Service Requester That Sends Requests to a Standard Asynchronous Reception (MDB (database queue)) in the manual Service Platform Basic Development Guide.

The following subsections describe the DB adapter message formats.

If the message format of a service requester for a DB adapter is different from the message format of a DB adapter message, data transformation is required. For details about data transformation, see Chapter 6. Defining Data Transformation in the manual Service Platform Basic Development Guide.

(a) Request message format

Create a request message in the XML document format.

Specify the elements, attributes, and text data, by conforming to W3C XML specifications. If you use a character that cannot be used for XML documents (such as <, >, or &), you need to escape such characters or use the CDATA section.

The request message format for when requesting execution of a single SQL statement is different from the request message format for when requesting execution of multiple SQL statements.

The request message format is shown below. Italic characters indicate variable values.

When requesting execution of a single SQL statement
Enter the SQL-identifier element as a lower element of the root element (DBadapter element). You can enter only one SQL-identifier element.
 
<DBadapter>
  <SQL-identifier out_maxOccurs="maximum-number-of-output-search-results">
    <DBA_IN_DATA>
      <argument-element nulldata="treatment-of-an-empty-element">argument-element-data</argument-element>
        :
    </DBA_IN_DATA>
  </SQL-identifier>
</DBadapter>
 

When requesting execution of multiple SQL statements
Enter the DBA_MULTI_SQL element as a lower element of the root element (DBadapter element). You can enter multiple DBA_MULTI_SQL elements. The maximum number of DBA_MULTI_SQL elements that can be entered is the value set for the MAX_SQL_NO element in the SQL operation definition file.
 
<DBadapter>
  <DBA_MULTI_SQL>
    <SQL-identifier out_maxOccurs="maximum-number-of-output-search-results">
      <DBA_IN_DATA>
        <argument-element nulldata="treatment-of-an-empty-element">argument-element-data</argument-element>
          :
      </DBA_IN_DATA>
    </SQL-identifier>
  </DBA_MULTI_SQL>
    :
</DBadapter>
 
(b) Elements and attributes of the request message

The table below lists and describes the elements and attributes of the request message. Note that the specification of the elements and attributes differs depending on the setting values in the SQL operation definition file. For details about the SQL operation definition file, see (1) Creating the SQL operation definition file.

Table 3-9 Elements and attributes of the request message

Element name or attribute name Type Description and setting value Type of setting value Can be omit
DBadapter Element This element is the root element, and has the following lower elements:

When requesting execution of a single SQL statement:
The lower element is the SQL-identifier element.

When requesting execution of multiple SQL statements:
The lower element is the DBA_MULTI_SQL element.
-- N
DBA_MULTI_SQL Element This element indicates that the request from a service requester requests execution of multiple SQL statements. Set the input information for the lower elements after SQL-identifier.
The maximum number of DBA_MULTI_SQL elements that can be entered is the value set for the MAX_SQL_NO element in the SQL operation definition file.

Note:
You cannot enter this element when requesting execution of a single SQL statement.
-- Y
SQL-identifier Element For SQL-identifier, specify the name of the SQL identifier specified in the SQL operation definition file.
Set the input information for the lower elements after DBA_IN_DATA.
The attribute includes out_maxOccurs.
-- Y
out_maxOccurs Attribute Specify the maximum number of output search results. Specify 0 or a larger value.

When the value is not specified:
The value of out_maxOccurs specified in the SQL operation definition file is set.

When 0 is set for the value:
The maximum number is set to 2,147,483,647.
xsd:int Y
DBA_IN_DATA Element Set the data for the argument elements set in the SQL operation definition file for the lower elements after argument-element. -- N
argument-element Element For argument-element, specify the name of the argument element specified in the SQL operation definition file.
The data for the argument element specified in the SQL operation definition file is stored in this element.
The attribute includes nulldata.

Note:
If the relevant SQL identifier has no argument element in the settings in the SQL operation definition file, you cannot set this element.
xsd:string or the setting value for data_type# N
nulldata Attribute Specify whether the data for the empty element is treated as null when dba_inf (argument type) specified in the SQL operation definition file is data. (You cannot specify this attribute if dba_inf is not data.)

If the data for the empty element is treated as null:
Specify Y.

If the data for the empty element is not treated as null:
Specify N.
Note that, if specification of this value is omitted, N is set for this attribute.
xsd:string
{Y|N}
Y

Legend:
--: This element or attribute has no setting value.
Y: This element or attribute can be omitted.
N: This element or attribute cannot be omitted.

#
The type of argument element to be stored depends on the value for dba_inf (argument type) specified for the relevant argument element in the SQL operation definition file. If dba_inf is table, column, or preset, the argument type is the xsd:string type. If dba_inf is data, follow the setting value of data_type (data type). For the correspondence between the setting values of data_type and the argument element types, see Table 3-10 and Table 3-11.
If dba_inf is data, you do not have to enclose the data to be stored in the argument element in single quotation marks (').

Table 3-10 Correspondence between the setting values for data_type and the argument element types (for HiRDB)

Setting value for data_type Argument element type
INTEGER xsd:int#
SMALLINT xsd:short#
DECIMAL xsd:string
FLOAT xsd:double#
REAL xsd:float#
CHAR xsd:string
VARCHAR xsd:string
DATE xsd:date#
TIME xsd:string
TIMESTAMP xsd:string
LONGVARBINARY xsd:hexBinary
xsd:base64Binary

#
You are also allowed to set an empty element.

Table 3-11 Correspondence between the setting values for data_type and the argument element types (for Oracle)

Setting value for data_type Argument element type
NUMERIC xsd:string
CHAR xsd:string
VARCHAR xsd:string
DATE xsd:date#
TIME xsd:string
TIMESTAMP xsd:string
LONGVARCHAR xsd:string
CLOB xsd:string
VARBINARY xsd:hexBinary
xsd:base64Binary
LONGVARBINARY xsd:hexBinary
xsd:base64Binary
BLOB xsd:hexBinary
xsd:base64Binary

#
You are also allowed to set an empty element.

Note that the values of argument elements set in the request message sent to the DB adapter are treated as shown in the following table.

Table 3-12 Treatment of argument elements in the request message sent to the DB adapter

Value of the argument element in the request message Setting value in the SQL operation definition file Value of the nulldata attribute in the request message Handling of the argument element
Attribute value dba_inf Attribute value for data_type
Empty element data -- Y or [Figure]Y[Figure]# null
Value other than Y or [Figure]Y[Figure] (including when specification of the value is omitted) Empty character string ("")
Other than data -- -- Empty character string ("")
Other elements data CHAR, VARCHAR, LONGVARCHAR, CLOB -- The space characters before and after the value are not deleted. <argument-element>[Figure]ABC[Figure]</argument-element> is treated as [Figure]ABC[Figure], where the space characters are not deleted.
Other than CHAR, VARCHAR, LONGVARCHAR, and CLOB -- The space characters before and after the value are deleted. <argument-element>[Figure]123[Figure]</argument-element> is treated as 123, where the space characters are deleted.
Other than data -- -- The space characters before and after the value are not deleted. <argument-element>[Figure]ABC[Figure]</argument-element> is treated as [Figure]ABC[Figure], where the space characters are not deleted.

Legend:
--: This value is not used for judgment.
[Figure]: One or more space characters (single-byte space character, line feed character, tab character)

#
Space characters before and after the attribute value of nulldata are ignored.

(c) Response message format

A response message is output in the XML document format.

If the search result (e.g., the column name) contains a character that cannot be used for XML documents, such a character is escaped and set in the response message. For example, if the search result contains < or &, these are escaped to &lt; or &amp;, respectively. Therefore, you do not have to escape the data stored in the database.

The response message format is different when responding to an execution request for a single SQL statement is different, from when responding to an execution request for multiple SQL statements.

The response message format is shown below. Italic characters indicate variable values.

When responding to an execution request for a single SQL statement
The SQL-identifier element is output as a lower element of the root element (DBadapter element).
 
<DBadapter>
  <SQL-identifier out_maxOccurs="maximum-number-of-output-search-results">
    <DBA_IN_DATA>
      <argument-element nulldata="treatment-of-an-empty-element">argument-element-data</argument-element>
        :
    </DBA_IN_DATA>
    <DBA_OUT_DATA>
      <DBA_ResultSetNo>SQL-return-value</DBA_ResultSetNo>
      <DBA_ResultSetXmlNo>number-of-search-results</DBA_ResultSetXmlNo>
      <DBA_ResultSetName>
        <DBA_ResultColumnName cid="column-number">column-name</DBA_ResultColumnName>
          :
      </DBA_ResultSetName>
      <DBA_ResultSet lid="line-number">
        <DBA_ResultColumn cid="column-number">search-result-of-the-relevant-n-th-column</DBA_ResultColumn>
          :
      </DBA_ResultSet>
        :
    </DBA_OUT_DATA>
  </SQL-identifier>
</DBadapter>
 

When responding to an execution request for multiple SQL statements
The DBA_MULTI_SQL element is output as a lower element of the root element (DBadapter element). As many DBA_MULTI_SQL elements as DBA_MULTI_SQL elements (written in the request message) are output.
 
<DBadapter>
  <DBA_MULTI_SQL>
    <SQL-identifier out_maxOccurs="maximum-number-of-output-search-results">
      <DBA_IN_DATA>
        <argument-element nulldata="treatment-of-an-empty-element">argument-element-data</argument-element>
          :
      </DBA_IN_DATA>
      <DBA_OUT_DATA>
        <DBA_ResultSetNo>SQL-return-value</DBA_ResultSetNo>
        <DBA_ResultSetXmlNo>number-of-search-results</DBA_ResultSetXmlNo>
        <DBA_ResultSetName>
          <DBA_ResultColumnName cid="column-number">column-name</DBA_ResultColumnName>
            :
        </DBA_ResultSetName>
        <DBA_ResultSet lid="line-number">
          <DBA_ResultColumn cid="column-number">search-result-of-the-relevant-n-th-column</DBA_ResultColumn>
            :
        </DBA_ResultSet>
          :
      </DBA_OUT_DATA>
    </SQL-identifier>
  </DBA_MULTI_SQL>
    :
</DBadapter>
 

Note that, if the input information in the request message is 0, the response message is output in the following format:

[Figure]

(d) Elements and attributes of the response message

The following table lists and describes the elements and attributes of the response message.

Table 3-13 Elements and attributes of the response message (service requester for a DB adapter)

Element name or attribute name Type Description and setting value Type of stored value Can be omitted
DBadapter Element This is the root element, and has the following lower elements:

When responding to an execution request for a single SQL statement:
The SQL-identifier element is output as the lower element.

When responding to an execution request for multiple SQL statements:
The DBA_MULTI_SQL element is output as the lower element.
-- N
DBA_MULTI_SQL Element This element indicates a response to an execution request for multiple SQL statements from the service requester. The input information (information set in the request message) and output information (SQL execution result) are output to the lower elements after SQL-identifier.
As many DBA_MULTI_SQL elements as DBA_MULTI_SQL elements (written in the request message) are output.
-- N#1
SQL-identifier Element The input information (information set in the request message) and output information (SQL execution result) are stored in the lower elements DBA_IN_DATA and DBA_OUT_DATA, respectively.
SQL-identifier is the SQL identifier set in the request message.
Note that the out_maxOccurs attribute (maximum number of output search results) is stored only when it is set in the request message.
-- N
DBA_IN_DATA Element Input information set in the request message is stored in the lower element of this element. -- N
DBA_OUT_DATA Element Information output when SQL is executed is stored in the lower element. The output information to be stored depends on the executed SQL statement.

When INSERT is executed:
DBA_ResultSetNo is stored as the lower element.

When SELECT is executed:
The following elements are stored as the lower elements:
  • DBA_ResultSetNo
  • DBA_ResultSetXmlNo
  • DBA_ResultSetName
  • DBA_ResultSet
-- N
DBA_ResultSetNo Element The output information to be stored depends on the executed SQL statement.

When INSERT is executed:
The number of updated lines (the value acquired by executeUpdate of the PreparedStatement class) is stored. The value to be stored when the element value exceeds 2,147,483,647 depends on the specifications of executeUpdate of the PreparedStatement class of the JDBC driver used by the DB Connector.

When SELECT is executed:
The number of search results is stored.
If the element value to be stored exceeds 2,147,483,647, 2,147,483,647 is stored.
xsd:int N
DBA_ResultSetXmlNo Element If the executed SQL instruction is SELECT, among the actual number of search results (DBA_ResultSetNo value), only the number of search results that are stored in this response message is stored.
If the DBA_ResultSetNo value is larger than the value specified for out_maxOccurs in the SQL operation definition file or in the request message, the value specified for out_maxOccurs is stored.
If the element value to be stored exceeds 2,147,483,647, 2,147,483,647 is stored.
xsd:int Y1
DBA_ResultSetName Element If the executed SQL instruction is SELECT, the column name of the search result is stored in the lower element DBA_ResultColumnName.
Note that, if the search result is 0, this element will not be stored.
-- Y2
DBA_ResultColumnName Element If the executed SQL instruction is SELECT, the name of the relevant column is stored.
Note that, if the resulted column is a column of the database, it is set in column-name format. If the resulted column name has not been acquired, a name that conforms with the specifications of the database to which the SQL statement was issued will be returned.
The attribute includes cid.
xsd:string Y2
cid Attribute Indicates the column number of the value to be stored in DBA_ResultColumnName. xsd:int
DBA_ResultSet Element If the executed SQL instruction is SELECT, the result for each line is stored in the lower element DBA_ResultColumn. Note that, if the search result is 0, this element will not be stored.
The attribute includes lid.
-- Y2
lid Attribute Indicates the line number of the value to be stored in DBA_ResultSet.
If the element value to be stored exceeds 2,147,483,647, 2,147,483,647 is stored.
xsd:int
DBA_ResultColumn Element The search result for the n-th column of the relevant line (the line indicated by DBA_ResultSet) will be stored.#2
The attribute includes cid and nulldata.
xsd:string Y2
cid Attribute Indicates the column number of the value to be stored in DBA_ResultColumn. xsd:int
nulldata Attribute Indicates whether the data stored in DBA_ResultColumn is null.
If the data is null, Y is set. If the data is not null, this attribute is not set.
xsd:string

Legend:
--: The value is not stored.
Y1: Output only when the SQL instruction is SELECT.
Y2: Output when the SQL instruction is SELECT and there are one or more execution results.
N: Always output. This element is not omitted.

#1
This element is always output when responding to an execution request for multiple SQL statements. This element is not output when responding to an execution request for a single SQL statement.

#2
The value acquired by getString of the ResultSet class is stored. Therefore, the format of the search result conforms to the specifications of getString of the ResultSet class of JDBC driver used by the DB Connector. If you want to change the format of the search result, use the function provided by the database for searching.
The following is an example of using the VARCHAR_FORMAT function to change the format of the TIMESTAMP type (column name: c_ts) of HiRDB.

 
SELECT VARCHAR_FORMAT(c_ts, 'YYYY-MONTH-DD HH:MI') FROM table-name