Page History
Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Introduction
This job The SQLExecutorJob template is used to execute SQL statements and SQL procedures in a database.
- The This job template makes use of JDBC connections and the Hibernate database access layer.
- The This job template can be used to access any database for which a JDBC Driver is available with for on the Agent.
- The JS7 includes a number of JDBC Drivers for supported DBMS, see see the JS7 - Database article.
- For other DBMS you DBMSs users can provide an individual JDBC Driver and store the that Driver's .jar file with in the .
/lib/user_lib
directory of the Agent installation.
- This job template supports use of a JS7 - Credential Store.
- Delimitation:
- Consider Note that specific SQL language extensions such as e.g. Oracle® PL/SQL are not supported by Hibernate.
- For Oracle® PL/SQL use the JS7 - JITL SOSPLSQLJobPLSQLJob.
- For Oracle® SQL*Plus use the JS7 - JITL SOSSQLPLUSJobSQLPLUSJob.
The job supports encryption of database credentials if used with a Hibernate configuration file, see JS7 - How to encrypt and decrypt Database Credentials.
Usage
When defining the job considereither:
- invoke the Wizard that is available from the job properties tab in the Configuration view and to select the JITL job class and SQLExecutorJob and the relevant arguments from the Wizard
or
- specify the
JITL
job class and to specify thecom.sos.jitl.jobs.db.SQLExecutorJob
Java class name and then add arguments as explained in the documentation below.
Example
Download: dbSQLExecutionConfigurationFile.json
A SQLExecutorJob configuration can look like this:
The job's arguments can be specified as follows:
Arguments
Documentation
The Job Documentation including the full list of arguments can be found under: https://www.sos-berlin.com/doc/JS7-JITL/SQLExecutorJob.xml
The SQLExecutorJob class accepts The com.sos.jitl.jobs.db.SQLExecutorJob
class accepts the following arguments:
Name | Required | Default Value | Purpose | Example |
---|---|---|---|---|
command | yes | Carries the SQL statements. | ||
| no | ./config/hibernate.cfg.xml | Specifies the configuration file (XML) format for Hibernate connections, see JS7 - Database. By default Agents ship without hibernate configuration files, however. However, if a file with the default name is available then it will be applied. | |
| no | Raises a warning if the SQL statement creates a result set. | ||
| no | If stored procedures are called that which return a result set are called then this argument has to be set to | ||
| no | Specifies how a result set is forwarded to order variables for subsequent jobs:
| ||
result_file | no | Specifies the path to a result file if the resultset_as_variables argument is used with one of the values csv, xml, json . An absolute path can be specified and a relative path can be used which starts from the Agent's working directory. | ||
credential_store_file | Location of a credential store database (*.kdbx) | false | ./config/private/jobs.kdbx | |
credential_store_key | Location of a credential store key file (*.key) | false | ./config/private/jobs.key |
Explanation:
- Note that it is possible to define more than one instruction with the
command
argument.
Such instructions are then carried out in the order in which they are written and must be separated by a semicolon.- Some DBMS might require and an additional newline character.
- For example:
update MY_TABLE set a='foo' where b='bar'; commit;
- Note also that order variables and arguments can be injected to the SQL statement(s) of the
command
argument by use of using the${variable}
syntax. - The SQLExecutorJob can be used with a credential store to hold sensitive arguments. For use of the
credential_store_*
arguments see JS7 - Use of Credential Store with JITL Jobs.
Further information
Cancellation
The following operations are available:
- The cancel operation is applied to the order, not to the SQLExecutorJob. In case of cancellation the job will continue until completion and the order will be set to the failed state.
- The cancel/force operation is applied to the order and to the job. The SQLExecutorJob will be forcibly terminated, any transactions will be rolled back, the database connection will be closed and the DBMS session will be terminated. The order will be set to the failed state.
Further Resources
- JS7 - JITL PLSQLJob
- JS7 - JITL SQLPLUSJob
- JS7 - JITL Common Variables
- JS7 - Job Resources
- JS7 - Use of Credential Store with JITL JobsJob Documentation:JobSchedulerManagedDatabaseJobSOSHibernate.xml