JDBC Query is an asynchronous activity that performs the specified SQL SELECT statement. If this activity is not part of a transaction group, the SQL statement is committed after the activity completes.
If this activity is part of a transaction group, the SQL statement is committed or rolled back with the other JDBC activities in the group at the end of the transaction.
If you want to override the default behavior of transaction groups for certain JDBC activities in a transaction group, you can select the Override Transaction Behavior check box on the Advanced tab. This specifies that the activity is outside of the transaction and the SQL statement is committed when the activity completes, even if the activity is in a transaction group.
The General tab has the following fields.
|Field||Literal Value/Module Property?||Description|
|Name||None||The name to be displayed as the label for the activity in the process.|
|JDBC Shared Resource||Yes||The path to the shared configuration resource containing the JDBC connection information. For details, refer to JDBC Connection|
|Timeout(sec)||Yes||The time (in seconds) to wait for the query to complete. If the query does not complete in the given time limit, an error is returned.|
|Maximum rows||Yes||The maximum number of rows to retrieve. To retrieve all rows, specify 0.|
The Statement tab has the following fields.
|Statement||This is the SQL SELECT statement to perform in the database. You can use a SQL Builder wizard to build the query for the desired database.|
Prepared Statement contains the
Parameter Name and
Data Type fields. All the parameters defined in the
Prepared Statement table are shown in the
Input tab of the activity for the user to provide values.
Each prepared statement corresponds to the question mark in the same position in the SQL statement. That is, the first prepared statement in the list corresponds to the first question mark, the second prepared statement in the list corresponds to the second question mark, and so on. The warning is for the purpose of information only. Ensure that the parameters in this field correctly correspond to the statement.
You can optionally specify names for each prepared parameter. By default, the prepared statements are named Parameter1, Parameter2, and so on. You must supply the datatype of each parameter to the SQL statement, and this data type is used in the input schema for the statement.
Execute the Query Button
Runs the JDBC Select statement entered in the Statement field and shows the results in the Results View. These results are persisted in the workspace.
Launch Eclipse SQL Builder. For more information on using the SQL Builder to visually build queries, go to: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.datatools.sqltools.doc.user%2Fdoc%2Fhtml%2Fasc1229700427574.html
Using the Fetch button on this activity, you can synchronize the activity with the contents of the database. When you first configure a JDBC activity, click the Fetch button to retrieve the schema for the output result set before applying your changes by saving your project.
After you have configured your activity, the Fetch button is useful when you make a change to the database while editing a process containing this activity. The Fetch button synchronizes with the database and changes the output schema, if necessary.
The Advanced tab has the following fields.
|ThreadPool SharedResource||Specifies a queue of threads available to run a queue of tasks. Thread pools are used to improve performance when executing large numbers of asynchronous tasks by reducing per task invocation overhead, provide a means of bounding, and managing the resources consumed when executing a collection of tasks.|
|Override Transaction Behavior|| Overrides the default behavior of a transaction group. If this activity is in a transaction group, the activity is normally committed or rolled back with the other transactional activities.
This activity is not part of the transaction group and is committed when it completes, when this check box is selected. Selecting this option uses a separate database connection to perform the activity and commit the SQL statement.
|Override JDBC Connection||Selecting this option overrides the default datasource connection, and allows for SQL queries to be executed against the optional datasource.
After selecting this option, the sharedResourceName field is enabled under the Input > Data Source tab. From the sharedResourceName field, type the complete path with the name of the optional datasource, which can be found under the Resources folder. For example, if a JDBC shared resource is located at Resources > Package_Name > JDBC_SR_Name, then the value you enter should be Package_Name.JDBC_SR_Name. The value you enter in the XPath Expression field is case sensitive and must be a string.
|Use Nil||Specifies whether NULLs are represented as optional schema elements or whether each item that can contain a NULL has subitems.|
|Interpret Empty String as Null||Specifies how empty strings in the activity’s input elements should be handled. Selecting this check box sends the nulls to the database where empty strings are supplied. Empty strings are treated as zero-length strings, when this check box is not selected. Whether you use this field or not, you can still use XPath to set input elements explicitly to null.|
|Process In Subsets||Selecting this check box specifies that you want to process the result set in smaller batches rather than processing the entire result set at once. When this check box is selected, the subsetSize input element is displayed for you to specify the size of each batch of records you want to process. Also, the lastSubset output element is displayed and is set to
true when the last batch of records is being processed.
Not selecting this check box returns the whole result set.
The following is the input for the activity.
|ServerTimeZone||string||Specifies the time zone for the database server.|
|timeout||number||The time (in seconds) to wait for the query to complete. If the query does not complete in the given time limit, an error is returned.|
|maxRows||number||The maximum number of rows to retrieve. To retrieve all rows, specify 0.|
The following is the output of the activity.
The Fault tab lists the possible exceptions thrown by this activity.
|JDBCConnectionNotFoundException||An error occurred when attempting to connect to the specified database.|
|InvalidTimeZoneException||An invalid time zone was specified.|
|JDBCSQLException||An SQL error occurred.|
|LoginTimedOutException||A timeout has occurred while attempting to connect to the database.|
|InvalidSQLTypeException||A parameter’s datatype does not match the datatype of the table column.|
|DuplicatedFieldNameException||A duplicate field name was specified.|
|ActivityTimedOutException||The operation has timed out.|