Lightweight Java Database Connectivity (JDBC) adapter
The Lightweight Java Database Connectivity (JDBC) adapter enables you to retrieve data from a JDBC-compliant database or update a JDBC-compliant database as part of a business process within Sterling B2B Integrator. This adapter is useful if you want to retrieve or manipulate data and need the flexibility of specifying various SQL queries.
The following table provides a high-level overview of the Lightweight JDBC adapter:
System name | None |
---|---|
Graphical Process Modeler (GPM) category | All services, Translation |
Description | Enables you to retrieve data from
a JDBC-compliant database or update a JDBC-compliant database as part
of a business process within the application, using one of the following
methods:
|
Business usage | Use the Lightweight JDBC adapter if you want to retrieve or manipulate data and need the flexibility of specifying various SQL queries. Use the JDBC adapter if you have complex output and you want to manipulate the data from a database and control the structure of the output. |
Preconfigured? | No |
Requires third party files? | You must configure a connection to an external database for the Lightweight JDBC adapter. |
Platform availability | All supported application platforms |
Related services | None |
Initiates business processes? | Yes |
Invocation | Runs by a schedule or business process |
How the Lightweight JDBC Adapter Works
The Lightweight JDBC adapter can start a business process or it can be used in a business process. This service can be scheduled to run at weekly or timed intervals.
The following figure shows how the Lightweight JDBC adapter communicates with a JDBC-compliant database:

Business Scenario
Your company receives information from an external database about a customer that needs to be either added (if the customer does not exist) or updated in your internal customer database. The customer information arrives in XML format.
Business Solution Example
- Configure a Lightweight JDBC adapter instance to be included in
a business process. This one instance of the Lightweight JDBC adapter
is used multiple times throughout the example business process to
perform the following tasks:
- Query the database for the customer ID passed into the business process to determine if the customer currently exists in the internal customer database.
- Add the customer information to the customer database if the customer does not exist.
- Update the customer information in the customer database if the customer does exist.
- Create a business process that determines whether to add or update the customer information to the internal customer database. The Lightweight JDBC adapter instance configured above is used in this business process to perform the query, add, and/or update.
- Configure a second Lightweight JDBC adapter instance to retrieve customer records from the external database and to start the business process created in the previous step. This Lightweight JDBC adapter instance is also scheduled to run at 10 p.m. daily to retrieve customer records from the external database and return the results to the business process.
GPM Example
The following example shows a solution to the business scenario using the GPM.
A Lightweight JDBC adapter has been configured and scheduled to retrieve records from an external database. The result from the query is the primary document to this business process.

The Assign statements are used to retrieve the customer information from the primary document and place the information into process data. The parameters specified for the Lightweight JDBC adapter, which includes customer information retrieved from process data and SQL statements, are input to the adapters. A primary document containing the results from the SQL statements issued against the database is output from the Lightweight JDBC adapter instances and is passed to the next step in the business process.
For information about the Lightweight JDBC parameters, see Implementing the Lightweight JDBC Adapter.
Business Process Modeling Language (BPML) Example
The following example shows the corresponding business process solution using BPML.
For information about the Lightweight JDBC parameters, see Implementing the Lightweight JDBC Adapter. For additional Lightweight JDBC adapter examples, including examples for using Oracle stored procedures and functions, see Lightweight JDBC Business Process Usage.
Implementing the Lightweight JDBC Adapter
- Configuring a Lightweight JDBC adapter instance to include in business processes. This lets you reuse the same Lightweight JDBC adapter instance to run different SQL queries against a database.
- Configuring a Lightweight JDBC instance that runs an SQL query and then starts a business process.
The information in this section applies to both implementation types.
- Collect the following information:
- The name of the business process (if the adapter is to start a business process)
- Database pool name used to connect to an external database
- Parameter values for the jdbc_customer.properties.in file (see Adding New Database Pools).
- Set up a connection to an external database, if you have not already done so. For information, see Setting Up a Connection to an External Database.
- Create a Lightweight JDBC adapter configuration. For information, see Managing Services and Adapters.
- Configure the Lightweight JDBC adapter. For information, see Configuring the Lightweight JDBC Adapter .
- Use the Lightweight JDBC adapter in a business process. Note: If the Lightweight JDBC adapter configuration starts a business process, create the business process prior to configuring the adapter.
Setting Up a Connection to an External Database
You must set up a connection to an external database for the Lightweight JDBC adapter. You can use any of the databases supported by the application for internal use or other JDBC-compliant databases, such as Sybase. For information about databases supported by the application, see System Requirements.
Adding New Database Pools
To define a new database pool for use by the Lightweight JDBC adapter, you must add settings for the pool to the jdbc_customer.properties.in file, which is located in the application's /install_dir/properties directory.
In jdbc_customer.properties.in, specify the database server name, port number, database/catalog name, user ID, and password. To encrypt your database password, use the encrypt_string.sh or encrypt_string.cmd utility in the bin directory. Then place the encrypted password, prefixed by an encryption indicator, in your properties file.
After you enter the information in the jdbc_customer.properties.in file, re-start the application.
If the database you want to connect to resides on a database server type that is not the same as the application's database server type, you also need to install a JDBC driver using the install3rdparty.sh or install3rdparty.cmd utility.
Select a table and column in your database to use in the test on reserve function. This function causes the application to test the database connection using a quickly run query before attempting to use it. This function ensures that idle connections are revived. The column referenced in the query should be of the type varchar and should be at least five characters in length.
Connecting to an External Database
- Add the necessary records to the jdbc_customer.properties.in file found in the
/install_dir/properties directory. Note: If invalid data (like
ABC
or13.45
) is entered in a pool setting, the setting uses its default value.See the examples that follow this procedure for Oracle 8i/9i, DB2, MS SQL 2000, and Sybase.
The following table contains the parameters needed to add a new database pool to the jdbc_customer.properties.in file:
Parameter Description databasePool.driver JDBC driver class file for the database application databasePool.url Database location (full URL as defined by the Java JDBC standards). Note: For Oracle systems, the last segment in the URL is the Oracle SID (not the System Reference or Tnsnames entry).databasePool.user Username for logging into the database databasePool.password Password for logging into the database databasePool.maxconn Maximum number of database connections for the connection pool. databasePool.storedProcClassName Specifies the class that handles stored procedure calls for the Lightweight JDBC adapter. The following classes are used for the database types: - MSSQL, Sybase, and DB2 – com.sterlingcommerce.woodstock.
util.frame.jdbc.GenericStoredProcQuery - Oracle 8i/9i – com.sterlingcommerce.woodstock.
util.frame.jdbc.OracleNoAppStoredProcQuery
databasePool.varDataClassName Each database that the application supports handles binary objects differently. This parameter specifies the class used to handle binary data for the database. Enter the correct class for your database: -
com.sterlingcommerce.woodstock.
util.frame.jdbc.DB2ISeriesVarData -
com.sterlingcommerce.woodstock.
util.frame.jdbc.DB2VarData -
com.sterlingcommerce.woodstock.
util.frame.jdbc.DB2ZOSVarData -
com.sterlingcommerce.woodstock.
util.frame.jdbc.JConnectVarData -
com.sterlingcommerce.woodstock.
util.frame.jdbc.MSSQLVarData -
com.sterlingcommerce.woodstock.
util.frame.jdbc.MySQLVarData -
com.sterlingcommerce.woodstock.
util.frame.jdbc.OracleBlobVarData -
com.sterlingcommerce.woodstock.
util.frame.jdbc.OracleVarData
databasePool.catalog Database name (usually the same as the last segment of the URL) databasePool.type Valid values: - local
- remote (default)
databasePool.testOnReserve Whether to test the connection. Valid values: - true
- false
Note: This function causes the application to test the database connection before attempting to use it and revives idle connections.databasePool.testOnReserveQuery SQL query to use when testing the connection . Select a table and column in your database to use in the test on reserve function. The column referenced in the query should be of the type varchar and should be at least five characters in length. This query needs to be executable by the databasePool.username account and must be a valid SQL query. For example:
SELECT table_name FROM user_tables WHERE table_name=?
Where ? must accept a string value. The query does not have to return a value to operate. If the query fails, the Database Pool is not activated.
databasePool.testOnReserveInterval The minimum number of milliseconds between running testOnReserve on the same connection. The default value is 60000. Valid values: - 0 - No interval and current interval is used.
- <= 0 - No interval.
- > 0 - The minimum number of milliseconds between running testOnReserve on the same connection.
databasePool.max8177RetryCount Only used for an Oracle database, this tells the software how many times to retry if it receives an ORA-8177 error in certain situations. databasePool.dbvendor Enter the database name: sybase, oracle, mssql, db2, db2zos, db2iseries, or other vendor name. databasePool.maxsize Maximum size of the database pool. This property was previously contained in the poolManager.properties file. This value must not exceed the value specified for the databasePool.maxconn parameter in the jdbc.properties file. databasePool.initsize Initial size of the database pool. This property was previously contained in the poolManager.properties file. databasePool.factory Always enter the following: com.sterlingcommerce.woodstock..
util.frame.jdbc.ConnectionFactorydatabasePool.behaviour Behavior a connection pool exhibits when it runs out of connections. This property replaces the databasePool.onEmpty property in the former poolManager.properties file. Valid values: - 0 – The pool simply returns indicating to the software to abort its current action and try again later. This value corresponds to the value return in the databasePool.onEmpty property.
- 1 – The pool waits the number of milliseconds specified in databasePool.waittime for a connection to be returned before indicating to the software to abort and try again. This value corresponds to the value wait in the databasePool.onEmpty property.
- 2 – The pool creates a buffered connection (a connection above the size specified in databasePool.maxsize). When using a setting of 2, the maximum number of connections for the pool is the value specified for databasePool.maxsize plus the value specified for databasePool.buffersize connections. This allows connections to be created under heavy demand. This value corresponds to the value new in the databasePool.onEmpty property.
databasePool.lifespan The number of milliseconds a connection will live in a given pool before it needs to be removed. - 0 – (Default) No timeout
- <= 0 – No timeout
- > 0 – Number of milliseconds that a connection stays in pool
databasePool.idletimeout The number of milliseconds a connection can stay idle in a given pool before it needs to be removed. The default value is 86400000. Valid values: - 0 – No timeout
- <= 0 – No timeout
- > 0 – Number of milliseconds that a connection stays in pool
databasePool.housekeepinginterval The minimum number of milliseconds between running the housekeeping task to clean out idle connections. Valid values are any positive number. The default value is 3600000 milliseconds (1 hour). Any number less than 3600000 will cause the default of 3600000 milliseconds to be used. databasePool.buffersize Number of extra connections that the connection pool can create above the value specified for databasePool.maxsize to improve handling of unanticipated loads on the system. This property is only used if databasePool.behavior is set to 2. databasePool.waittime Amount of time (in milliseconds) to wait for a connection to become available before indicating to the software to abort the current action and try again later. This property is only used if databasePool.behavior is set to 1. databasePool.transaction Determines whether the dbpool can participate in distributed transactions. Valid values: true – if true, the databasePool.type value should be remote or should not be declared. false (default). The following pools cannot participate in distributed transactions at this time: Local Pool, noTrans Pool, and Yantra Pool.
- MSSQL, Sybase, and DB2 –
- If you are encrypting your database password, use the encrypt_string.sh or encrypt_string.cmd utility in the bin directory. Then, place the encrypted password, prefixed by an encryption indicator, in your jdbc.properties.in file entry.
- If the vendor for the connection database is not the same vendor
as the database vendor used for the application's database, install
the appropriate JDBC driver to access the database server. Use the
install3rdParty.sh (UNIX) or install3rdparty.cmd (Windows) utility
located in the /install_dir/bin directory of the application's
installation directory to add the JDBC driver jar files. Type install3rdParty on
the command line to get a description of the parameters you can specify.
The following examples are for a UNIX environment. The vendor name and version are the first two parameters, along with the location of the .zip file containing the JDBC driver files.
- For Oracle 9i, install the driver using the following command:
./install3rdParty.sh Oracle 9_2_0_5 -d /
usr/
local/
directory/oracle/9_2_0_5/classes12.zip
- For DB2, install the driver using the following command:
./install3rdParty.sh db2java 7_2 -d /
usr/
local/
directory/db2java.zip
- To install the jConnect driver for Sybase, refer to Installing a Sybase Driver.
- For Oracle 9i, install the driver using the following command:
- Stop and restart the application to use the changed files.
Installing a Sybase Driver
- Download jConnect-5_5.zip from the Sybase web site.
- Run the following command:
./install3rdParty.sh jconnect 5_5 -d /
usr/
local/
directory/5_5/jConnect-5_5.zip
- If this command succeeds, you are finished with this procedure.
- If the application reports in the system log that the driver could not be registered because the driver class cannot be found, continue with the procedure. Use the following steps to remove existing references to jConnect.
- Stop the application.
- Change your directory to install_dir/jar.
- Delete any existing folders referencing jConnect.
- Change your directory to install_dir/properties.
- Open the files dynamicclasspath.cfg and dynamicclasspath.cfg.in. Delete any lines referencing jConnect, and save the files.
- Create the following temporary directory:
install_dir/bin/jconnect
- Extract only the jar files from jConnect-5_5.zip to this directory.
- Run the following command:
install3rdparty jconnect 5_5 -d
install_dir/bin/jconnect/*.jar
- Check install_dir/jar/jconnect/5_5/your_platform to make sure that six jar files have been copied successfully.
- Open the dynamicclasspath.cfg file in install_dir/properties
and check that the following entries are there:
VENDOR_JAR=/install_dir/jar/jconnect/5_5/your_platform/jconn2.jar VENDOR_JAR=/install_dir/jar/jconnect/5_5/your_platform/jconn2d.jar VENDOR_JAR=/install_dir/jar/jconnect/5_5/your_platform/jisql.jar VENDOR_JAR=/install_dir/jar/jconnect/5_5/your_platform/jTDS2.jar VENDOR_JAR=/install_dir/jar/jconnect/5_5/your_platform/jTDS2d.jar VENDOR_JAR=/install_dir/jar/jconnect/5_5/your_platform/ribo.jar
- Open the customer.jdbc.properties.in file in install_dir/properties and
check that the following entries are
there:
jconnectPool.driver=com.sybase.jdbc2.jdbc.SybDriver jconnectPool.url=jdbc:sybase:Tds:your Hostname:4100/your DB jconnectPool.user=your user name jconnectPool.password=your password jconnectPool.catalog=your database jconnectPool.type=local jconnectPool.testOnReserve=true jconnectPool.testOnReserveQuery=your Test On Reserve Query jconnectPool.dbvendor=Sybase jconnectPool.buffersize=500 jconnectPool.maxsize=28 jconnectPool.initsize=1 jconnectPool.behaviour=2 jconnectPool.waittime=1000 jconnectPool.storedProcClassName= com.sterlingcommerce.woodstock.util. frame.jdbc.SybaseStoredProcQuery jconnectPool.varDataClassName=com.sterlingcommerce.woodstock.util. frame.jdbc.JConnectVarData jconnectPool.factory=com.sterlingcommerce.woodstock.util.frame.jdbc. ConnectionFactory
- Save the customer.jdbc.properties.in file and run the following
command:
install_dir/bin/setupfiles.sh
This procedure should result in a successful connection to your Sybase database. However, if the database has been configured as character set ROMAN8, it is likely that you will see the following message in the application system log, because of a limitation in the Sybase driver:
java.sql.SQLWarning: JZ0IB: The server's default
charset of roman8 does not map to an encoding that is available
in the client Java environment. Because jConnect will not be able
to do client-side conversion, the connection is unusable and is
being closed. Try using a later Java version or try including your
Java installation's i18n.jar or charsets.jar file in the clasps
One resolution of this issue is to configure the primary Adaptive Server with a default character set that maps to one of the character sets supported by jConnect for JDBC (for example, UTF-8). For more details, refer to the Sybase documentation.
- Stop the application.
- Remove references to jConnect as described previously.
- Copy the jtds-1.2.jar file to an accessible directory on the application machine.
- Run the following command:
install_dir
/bin/Install3rdparty.sh jTDS 1_2 - jar
absolutePath/jtds-1.2.jar
- Check that the dynamicclasspath.cfg file has picked up this change. For example, /install_dir/jar/jTDS/1_2/your_platform/jtds-1.2.jar.
- Edit the jdbc_customer.properties.in file. The definition of the pool should be similar to the
following
example:
jTDSPool.driver=net.sourceforge.jtds.jdbc.Driver
jTDSPool.url=jdbc:jtds:sybase://your Hostname:4100/answer
jTDSPool.user=your user name jTDSPool.password=your password jTDSPool.catalog=your database jTDSPool.type=local jTDSPool.testOnReserve=false #jTDSPool.testOnReserveQuery=your Test On Reserve Query jTDSPool.dbvendor=jtds jTDSPool.buffersize=50 jTDSPool.maxsize=20 jTDSPool.initsize=5 jTDSPool.behaviour=2 jTDSPool.storedProcClassName=com.sterlingcommerce.woodstock.util. frame.jdbc.SybaseStoredProcQuery jTDSPool.varDataClassName=com.sterlingcommerce.woodstock.util. frame.jdbc.GenericVarData jTDSPool.factory=com.sterlingcommerce.woodstock.util.frame.jdbc. ConnectionFactory - Restart the application.
Properties File Examples for Specific Databases
Oracle 8i/9i
For Oracle 8i/9i, enter the following parameters in the jdbc_customer.properties.in file, where databasePool is the name of the pool you are adding. Sample values are italicized; enter the correct value for your environment instead of the sample value. Values that are not italicized are the actual values that you should enter for the parameter:
databasePool.driver=oracle.jdbc.driver.OracleDriver
databasePool.url=jdbc:oracle:thin:@servername:0000:servername
databasePool.user=username
databasePool.password=password
databasePool.catalog=catalogname
databasePool.type=local
databasePool.testOnReserve=true
databasePool.testOnReserveQuery=SELECT TestConnection from
Connection_tb WHERE TestConnection = ?
databasePool.testOnReserveInterval=60000
databasePool.max8177RetryCount=n
databasePool.dbvendor=oracle
databasePool.buffersize=n
databasePool.maxsize=n
databasePool.initsize=n
databasePool.behaviour=n
databasePool.lifespan=0
databasePool.idletimeout=86400000
databasePool.housekeepinginterval=3600000
databasePool.waittime=n databasePool.storedProcClassName=
com.sterlingcommerce.woodstock.util.frame.jdbc.OracleNoAppStoredProcQuery
databasePool.varDataClassName=com.sterlingcommerce.woodstock.util.
frame.jdbc.OracleVarData
databasePool.factory=com.sterlingcommerce.woodstock.util.frame.jdbc.
ConnectionFactory
DB2
For DB2, enter the following parameters in the jdbc_customer.properties.in file, where databasePool is the name of the pool you are adding. Sample values are italicized; enter the correct value for your environment instead of the sample value. Values that are not italicized are the actual values that you should enter for the parameter:
databasePool.driver=com.ibm.as400.access.AS400JDBCDriver
databasePool.url=jdbc:as400://serverName/DB2Database;translate binary=true;
transaction isolation=none;
databasePool.catalog=DB2Database
databasePool.varDataClassName=com.sterlingcommerce.woodstock.util.frame.
jdbc.DB2ISeriesVarData
databasePool.user=username
databasePool.password=password
databasePool.maxconn=20
databasePool.testOnReserve=true
databasePool.testOnReserveQuery=SELECT SI_VERSION from SI_VERSION where
SI_VERSION = ?
databasePool.testOnReserveInterval=60000
databasePool.blobPageSize=1024000
databasePool.compressBlob=true
databasePool.dbvendor=db2iSeries
databasePool.buffersize=500
databasePool.maxsize=20
databasePool.initsize=0
databasePool.factory=com.sterlingcommerce.woodstock.util.frame.jdbc.
ConnectionFactory
databasePool.behaviour=2
databasePool.lifespan=0
databasePool.idletimeout=86400000
databasePool.housekeepinginterval=3600000
databasePool.waittime=1000
MS SQL 2000
For MS SQL 2000, enter the following parameters in the jdbc_customer.properties.in file, where databasePool is the name of the pool you are adding. Sample values are italicized; enter the correct value for your environment instead of the sample value. Values that are not italicized are the actual values that you should enter for the parameter:
databasePool.driver=com.microsoft.jdbc.sqlserver.SQLServerDriver
databasePool.url=jdbc:microsoft:sqlserver://servername:0000;
DatabaseName=SQLdatabase;SelectMethod=cursor
databasePool.user=username
databasePool.password=password
databasePool.catalog=catalogname
databasePool.type=local
databasePool.testOnReserve=true
databasePool.testOnReserveQuery=SELECT TestConnection from
Connection_tb WHERE TestConnection = ?
databasePool.testOnReserveInterval=60000
databasePool.dbvendor=mssql
databasePool.buffersize=n
databasePool.maxsize=n
databasePool.initsize=n
databasePool.behaviour=n
databasePool.lifespan=0
databasePool.idletimeout=86400000
databasePool.housekeepinginterval=3600000
databasePool.waittime=n
databasePool.storedProcClassName=com.sterlingcommerce.woodstock.util.
frame.jdbc.GenericStoredProcQuery
databasePool.varDataClassName=com.sterlingcommerce.woodstock.util.
frame.jdbc.MSSQLVarData
databasePool.factory=com.sterlingcommerce.woodstock.util.frame.jdbc.
ConnectionFactory
Sybase
For Sybase, enter the following parameters in the jdbc_customer.properties.in file, where databasePool is the name of the pool you are adding. Sample values are italicized; enter the correct value for your environment instead of the sample value. Values that are not italicized are the actual values that you should enter for the parameter:
databasePool.driver=com.sybase.jdbc2.jdbc.SybDriver
databasePool.url=jdbc:sybase:Tds:servername:0000/SybaseDB
databasePool.user=username
databasePool.password=password
databasePool.catalog=catalogname
databasePool.type=local
databasePool.testOnReserve=true
databasePool.testOnReserveQuery=SELECT TestConnection from
Connection_tb WHERE TestConnection = ?
databasePool.testOnReserveInterval=60000
databasePool.dbvendor=Sybase
databasePool.buffersize=n
databasePool.maxsize=n
databasePool.initsize=n
databasePool.behaviour=n
databasePool.lifespan=0
databasePool.idletimeout=86400000
databasePool.housekeepinginterval=3600000
databasePool.waittime=n
databasePool.storedProcClassName=com.sterlingcommerce.woodstock.util.
frame.jdbc.SybaseStoredProcQuery
databasePool.varDataClassName=com.sterlingcommerce.woodstock.util.
frame.jdbc.JConnectVarData
databasePool.factory=com.sterlingcommerce.woodstock.util.frame.jdbc.
ConnectionFactory
Encrypting Your Database Password
- Use encrypt_string.sh (UNIX) or encrypt_string.cmd (Windows).
- When prompted, enter your external database password.
The script returns the encrypted value for your password.
- Place the encrypted password in the jdbc.properties.in file entry (see Connecting to an
External Database), prefixing the encrypted password with ENCRYPTED.
For example, databasePool.password=ENCRYPTED:rO0ABXQABkRFU2VkZXVy
Configuring the Lightweight JDBC Adapter
To configure the Lightweight JDBC adapter, you must specify field settings in the application and in the GPM.
Application Configuration Parameters
The following table describes the fields used to configure the Lightweight JDBC adapter:
Field | Description |
---|---|
Name (Config) | Unique and meaningful name for the adapter configuration. Required. |
Description | Meaningful description for the adapter configuration, for reference purposes. Required. |
Select a Group | Select one of the options:
|
Start a new business process (StartNewWorkFlow) | Whether to start a new business process . Valid
values:
|
Run as User | Enter (or select from the list) the user ID to be associated with business process instances of this service. |
Use 24 Hour Clock Display | Select to specify times for this schedule using the 24 hour clock. Leave blank to use 12 hour clock and AM and PM. |
Schedule | Information about scheduling the Lightweight JDBC
adapter configuration to run and to start the specified business process.
Valid values:
Note: The Schedule field only displays as an option if you set
the Start a new business process parameter to “This Lightweight
JDBC adapter configuration starts a new business process.”
|
Business process (InitialWorkFlowId) | Business process you want the Lightweight JDBC adapter to start, if any. Required if you set the Start a new business process parameter to “This Lightweight JDBC adapter configuration will start a new business process.” |
Pool Name | Select the database pool to be used. |
XML Result Root Tag (result_name) | The root tag element you want to appear in the
XML document returned from the Lightweight JDBC adapter after a query.
This document contains the results from the SQL
query and becomes the primary document. For example, if you specify
RootResultXmlElement as the name for the XMLResult Root Tag, the following
results are displayed in the returned XML document for an ACTION query:
|
XML Result Row Tag (row_name) | Row tag XML element containing all the column tags
returned from the SQL query. The column tag names are not configurable.
The tag names are generated by the column name returned in the result
set. Required. For example, if you specify ResultsFromUpdate as the name for the XML Result Row Tag, the following results are displayed in the returned XML document for an ACTION query.
|
Query Type (query_type) | Result set or the number of rows affected by an
action query returned by the SQL statement.
Required. Valid values:
|
Notes for stored procedures and functions:
|
|
SQL Statement (sql) | Hard-coded SQL query that queries a database. It
must be in valid SQL syntax. Note: You can specify the SQL query
either using this field or when you add the Lightweight JDBC adapter
instance in a business process.
|
GPM Configuration
The following screen shows the graphical view of the GPM parameters for the Lightweight JDBC adapter. Values for the inactive fields were specified using the Lightweight JDBC adapter configuration. The active fields cannot be configured in the application or are being overridden. None of the fields on the Message From Service tab require configuration.
The following example shows the corresponding BPML parameters for the Lightweight JDBC adapter GPM parameters. This example business process takes the primary document, which contains the query results, and writes it to process data.
<process name="ExampleLWJDBC">
<operation name="LWJDBC - QueryForCustomerID">
<participant name="ExampleLWJDBCBusinessProcess"/>
<output message="LightweightJDBCAdapterTypeInputMessage">
<assign to="param1" from="number(/ProcessData/CustomerInformation/
ResultsFromQuery/Customer[number(//NumberOfRecords)]/customer_id/text())"/>
<assign to="paramtype1">Integer</assign>
<assign to="query_type">SELECT</assign>
<assign to="sql">SELECT COUNT(*) AS CUSTOMERS FROM CUSTOMER2 WHERE
CUSTOMER_ID = ?</assign>
<assign to="." from="*"/>
</output>
<input message="inmsg">
<assign to="NumberOfCustomers" from="DocToDOM(PrimaryDocument)/
ResultsFromSQL/CUSTOMERS"/>
</input>
</operation>
</sequence>
</process>
The following table describes the fields used to configure the Lightweight JDBC adapter in the GPM. This table contains only the fields that are configured in the GPM. See Configuring the Lightweight JDBC Adapter for parameters you can specify in either the GPM or in the configuration for your application.
Field | Description |
---|---|
Config | Name of the service configuration. |
param1 - param20 | Specifies the values that are passed to the SQL statement that is to be executed against the database. You can either specify constant values or use XPath query statements to retrieve information from process data to pass to the SQL statement. If you use XPath query statements, you must also select the “Use XPath?” check box in the Service Editor of the GPM for the parameter. See the Lightweight JDBC Business Process Usage section for an example of using Xpath to set these values. Optional. |
paramtype1 - paramtype20 | Parameter type that corresponds to the parameter
number (for example, param1 and paramtype1). Every parameter specified
must have a corresponding parameter type. Valid values:
|
Large Text Data Support
- CharacterStream is used to insert or update data to the database that is in process data.
- CharacterStreamFromDocument is used to insert or update data to the database from the primary document.
To insert data to the database or to update the database using the CharacterStream or CharacterStreamFromDocument values, there are two new query types: INSERT and UPDATE.
There is also a parameter that you can add to your business process manually (this parameter is not available through the GPM): write_characterstream_to_document. Valid values for this parameter are YES and NO. This parameter enables you to place the contents of large data inside of a document during a SELECT query, because XML has size limitations on pcdata. The primary document will still contain the result tree but the name of the document will replace the large data. The write_characterstream_to_document parameter defaults to YES. The LOB streaming support has a maximum limit of 4 GB, but the actual LOB streaming support limit depends on the database and the JDBC driver being used.
The following example illustrates using the parameter to write the contents of the data returned from the database directly to a document:
<operation name="LightweightJDBCAdapterType">
<participant name="LightweightJDBCAdapterQuery"/>
<output message="LightweightJDBCAdapterTypeInputMessage">
<assign to="result_name">result</assign>
<assign to="sql">SELECT ID, XML_MESSAGE FROM CUSTOMER WHERE
CUSTOMER_ID=?</assign>
<assign to="pool">mysqlPool_local</assign>
<assign to="param1" from="customer_id/text()" />
<assign to="paramtype1">String</assign>
<assign to="write_characterstream_to_document">Yes</assign>
<assign to="row_name">row</assign>
<assign to="query_type">SELECT</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
This is a sample of what you would see in the primary document:
<?xml version="1.0" encoding="UTF-8"?>
<result>
<row>
<ID>1</ID>
<XML_MESSAGE>doc-1</XML_MESSAGE>
</row>
</result>
The parameter types are used by the Lightweight JDBC adapter to insert or update large text data into the database. The insert and update statements differ in how they are implemented, so you must specify the INSERT or UPDATE action type. Several examples follow.
Example 1
Updates the column with the contents of the primary document. In this example, the parameter type is CharacterStreamFromDocument, so the parameter value is not required; instead, the value is taken from the primary document.
<operation name="LightweightJDBCAdapterType">
<participant name="LightweightJDBCAdapterQuery"/>
<participant name="LightweightJDBCAdapterQuery"/>
<output message="LightweightJDBCAdapterTypeInputMessage">
<output message="LightweightJDBCAdapterTypeInputMessage">
<assign to="result_name">resul</assign>t<assign to="result_name">result</assign>
<assign to="sql">UPDATE CUSTOMER SET XML_MESSAGE=? WHERE
CUSTOMER_ID=</assign>?<assign to="sql">UPDATE CUSTOMER SET XML_MESSAGE=?
WHERE CUSTOMER_ID=?</assign>
<assign to="paramtype1">CharacterStreamFromDocumen</assign>t<assign to
="paramtype1">CharacterStreamFromDocument</assign>
<assign to="param2" from="customer_id/text()" /><assign to="param2"
from="customer_id/text()" />
<assign to="paramtype2">Strin</assign>g<assign to="paramtype2">String</assign>
<assign to="pool">mysqlPool_loca</assign>l<assign to="pool">mysqlPool_local</assign>
<assign to="row_name">ro</assign>w<assign to="row_name">row</assign>
<assign to="query_type">UPDAT</assign>E<assign to="query_type">UPDATE</assign>
<assign to="." from="*"</assign>><assign to="." from="*"></assign>
</output></output>
<input message="inmsg"><input message="inmsg">
<assign to="." from="*"</assign>><assign to="." from="*"></assign>
</input></input>
</operation>
Example 2
Updates a column with the string returned from an Xpath query against process data. In this example, the CharacterStream parameter type is used, so the parameter value is required.
<operation name="LightweightJDBCAdapterType">
<participant name="LightweightJDBCAdapterQuery"/>
<output message="LightweightJDBCAdapterTypeInputMessage">
<assign to="result_name">result</assign>
<assign to="sql">UPDATE CUSTOMER SET XML_MESSAGE = ?
WHERE CUSTOMER_ID=?</assign>
<assign to="paramtype1">CharacterStream</assign>
<assign to="param1" from="rootNode/SampleText2/text()"></assign>
<assign to="param2" from="customer_id/text()" />
<assign to="paramtype2">String</assign>
<assign to="pool">mysqlPool_local</assign>
<assign to="row_name">row</assign>
<assign to="query_type">UPDATE</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
Example 3
Inserts a row with the string returned from an Xpath query against process data.
<operation name="LightweightJDBCAdapterType">
<participant name="LightweightJDBCAdapterQuery"/>
<output message="LightweightJDBCAdapterTypeInputMessage">
<assign to="result_name">result</assign>
<assign to="sql">INSERT INTO CUSTOMER (CUSTOMER_ID, XML_MESSAGE)
VALUES (?, ?) </assign>
<assign to="param1" from="customer_id/text()" />
<assign to="paramtype1">String</assign>
<assign to="paramtype2">CharacterStream</assign>
<assign to="param2" from="rootNode/SampleText/text()"></assign>
<assign to="pool">mysqlPool_local</assign>
<assign to="row_name">row</assign>
<assign to="query_type">INSERT</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
Example 4
Writes the contents of the data returned from a database directly to a document (note that this is not the primary document). The primary document will still contain the XML result tree; however, the data in the document is replaced by a document name.
<operation name="LightweightJDBCAdapterType">
<participant name="LightweightJDBCAdapterQuery"/>
<output message="LightweightJDBCAdapterTypeInputMessage">
<assign to="result_name">result</assign>
<assign to="sql">SELECT XML_MESSAGE FROM CUSTOMER WHERE
CUSTOMER_ID=?</assign>
<assign to="pool">mysqlPool_local</assign>
<assign to="param1" from="customer_id/text()" />
<assign to="paramtype1">String</assign>
<assign to="write_characterstream_to_document">Yes</assign>
<assign to="row_name">row</assign>
<assign to="query_type">SELECT</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
This is an example of what you should expect to see in the primary document:
<?xml version="1.0" encoding="UTF-8"?>
<result>
<row>
<XML_MESSAGE>doc-1</XML_MESSAGE>
</row>
</result>
This is an Oracle example for updating a clob column. The first parameter is used to find the row in the table. The second parameter will be used to update the value.
<operation name="LightweightJDBCAdapterType">
<participant name="LightweightJDBCAdapterQuery"/>
<output message="LightweightJDBCAdapterTypeInputMessage">
<assign to="result_name">result</assign>
<assign to="sql">SELECT XML_MESSAGE FROM CUSTOMER WHERE
CUSTOMER_ID=?for update</assign>
<assign to="param1" from="customer_id/text()" />
<assign to="paramtype1">String</assign>
<assign to="paramtype2">CharacterStream</assign>
<assign to="param2" from="rootNode/SampleText2/text()"></assign>
<assign to="pool">oracleTestPool</assign>
<assign to="row_name">row</assign>
<assign to="query_type">UPDATE</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
Lightweight JDBC Business Process Usage
This section contains additional examples using the Lightweight JDBC adapter, including sample configurations for using Oracle stored procedures and functions.
The following sample document is the primary document passed to the business process for the SELECT and ACTION query type examples.
<Customer Id="2">
<Name/>
<Address/>
<Phone/>
</Customer>
SELECT Query Type Example
The following example using the GPM illustrates a business process that uses the Lightweight JDBC adapter to SELECT customer information based on the customer ID passed into the business process.
The following example illustrates the same business process using BPML.
Message to the Lightweight JDBC Adapter Instance
The following example shows the message sent to the Lightweight JDBC adapter when you run the business process. The message uses the parameters defined within the <output> tags of the Lightweight JDBC adapter definition in the previous BPML example, along with the parameters defined during configuration of the adapter instance.
<LightweightJDBCAdapterTypeInputMessage>
<row_name>ResultsFromSQL</row_name>
<StartNewWorkFlow>NO</StartNewWorkFlow>
<result_name>RootResultXmlElement</result_name>
<pool>mysqlTrainingPool</pool>
<query_type>SELECT</query_type>
<XMLVersion>3.0</XMLVersion>
<param1>2</param1>
<paramtype1>Integer</paramtype1>
<sql>SELECT * FROM Customer WHERE CUSTOMER_ID = ?</sql>
</LightweightJDBCAdapterTypeInputMessage>
Message from the Lightweight JDBC Adapter Instance
The following example shows the table definition used to query against the Lightweight JDBC adapter. In the previous BPML example, the assign statement within the <input> tags of the Lightweight JDBC adapter definition (<assign to="." from="."></assign>) indicates that the results are returned as a primary document.
create table customer(customer_id NUMERIC not null,
customer_name varchar(255),
customer_address varchar(100),
customer_phone varchar(20));
Notice how the columns from the Customer table become XML elements in the results returned from the Lightweight JDBC adapter, as shown below in the message returned from the Lightweight JDBC adapter.
ACTION Query Type Example
The following example using the GPM illustrates a business process that uses the Lightweight JDBC adapter to delete customer information from a database.

The following example illustrates the same business process using BPML.
Message to the Lightweight JDBC Adapter Instance
The following example shows the message sent to the Lightweight JDBC adapter when you run the business process. The message uses the parameters defined within the <output> tags of the Lightweight JDBC adapter definition in the previous BPML, along with the parameters defined for the Lightweight JDBC adapter instance during configuration.
<?xml version="1.0" encoding="UTF-8"?>
<LightweightJDBCAdapterTypeInputMessage>
<row_name>ResultsFromSQL</row_name>
<StartNewWorkFlow>NO</StartNewWorkFlow>
<result_name>RootResultXmlElement</result_name>
<pool>mysqlTrainingPool</pool>
<query_type>ACTION</query_type>
<XMLVersion>3.0</XMLVersion>
<param1>2</param1>
<paramtype1>Integer</paramtype1>
<sql>DELETE FROM CUSTOMER WHERE CUSTOMER_ID=?</sql>
</LightweightJDBCAdapterTypeInputMessage>
Message from the Lightweight JDBC Adapter Instance
The following example shows the message returned from the Lightweight JDBC adapter to the business process. The assign statement within the <input> tags of the Lightweight JDBC adapter definition (<assign to="." from="."></assign>) indicates that the results are returned as a primary document.
Calling Oracle Stored Procedures
- The Lightweight JDBC adapter processes only one result set if you script multiple queries to run in stored procedures.
- The first argument in an Oracle stored procedure must be declared as an output parameter, it must be an integer, and the stored procedure must return a value to this parameter even if the value is not needed in the business process.
- You must specify a value for the first parameter (param1) in the Lightweight JDBC adapter instance to correspond with the first argument of the stored procedure, even if the parameter is not used in the stored procedure.
Stored Procedure Example
The following example shows a database script for creating an Oracle stored procedure. The stored procedure updates the account status for a customer. Notice that the first argument of the stored procedure is declared as an output parameter and is set to a number, even though this value will not be used in the business process.
CREATE OR REPLACE PROCEDURE P_Update_Account(v_dummy OUT number,
v_customer_id IN number, v_account_id number, v_status IN varchar2)
AS
BEGIN
UPDATE
ACCOUNT
SET
STATUS = v_status
WHERE
ACCOUNT_ID = v_account_id
AND
CUSTOMER_ID=v_customer_id;
COMMIT;
v_dummy:= '4';
END;
/
The following sample document is the primary document passed into the example business process used to call the stored procedure.
<PurchaseOrder>
<Account Id="100">
<Customer Id="2"/>
<Status>ACTIVE</Status>
</Account>
</PurchaseOrder>
The following example using the GPM illustrates a business process that uses the Lightweight JDBC adapter to start the stored procedure.
The following example illustrates the same business process using BPML:
Calling Oracle Functions
The following example shows a database script for creating a simple Oracle function. The function retrieves and returns the number of products in the database.
CREATE OR REPLACE FUNCTION product_count
RETURN number
IS
V_product_count number;
BEGIN
SELECT count(*) INTO v_product_count
FROM product;
RETURN v_product_count;
END;
/
The following example using the GPM illustrates a business process that uses the Lightweight JDBC adapter to start the function:
The following example illustrates the same business process using BPML:

<assign to="sql">{? = call product_count()}</assign>