uCosminexus Service Platform, Overview

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

2.6.1 Accessing a database using DB adapters

A DB adapter enables direct access to a database when receiving requests from a service requester and a business process. Database access follows the SQL statement defined in the database adapter.

Organization of this subsection
(1) Executing SQL statements by using database adapters
(2) Binary data operations

(1) Executing SQL statements by using database adapters

You can define the DB adapter in the development environment. In the service requester that sends a request to the DB adapter, create an XML document writing the SQL statement to be executed. Then, specify the created XML message in the request message, and then execute the process. The following figure shows the execution of an SQL by using a DB adapter.

Figure 2-45 Executing an SQL by using a DB adapter

[Figure]

For details about how to define the DB adapter and how to create a service requester that sends requests to the DB adapter, see 3.3.5 Defining a database adapter in the Service Platform Basic Development Guide.

(2) Binary data operations

In a DB adapter, binary data is handled as a byte array type, and base64Binary and hexBinary types are handled as String type. The following describes examples of operating the BLOB type for executing the SELECT statement and for executing the INSERT statement.

(a) Processing when executing the SELECT statement

If you execute the SELECT statement for the BLOB column, the DB adapter converts (encodes) the byte array to the base64Binary or hexBinary type of XML Schema. Then, the value of the BLOB column is returned to the request source.

Figure 2-46 Processing when executing the SELECT statement (conversion to the base64Binary type)

[Figure]

(b) Processing when executing the INSERT statement

If you execute the INSERT statement for the BLOB column, the request source passes the base64Binary or hexBinary type data of XML Schema to the DB adapter. The DB adapter converts (decodes) the base64Binary or hexBinary type data to a byte array, and then the INSERT statement is executed.

Figure 2-47 Processing when executing the INSERT statement (conversion from the base64Binary type)

[Figure]

If an error occurs during conversion (decoding) of xsd:hexBinary or xsd:base64Binary type data, the message KDEC63001-E is output (with cause code 22 for the xsd:hexBinary type, or cause code 23 for the xsd:base64Binary type). If the Convert a system exception into a fault message option is enabled during definition of the DB adapter, a fault message will be output to the caller of the DB adapter. If this option is disabled, a system exception will be sent.