Users can specify different datasources for the jdbc-item reader and or jdbc-item writer

Users can specify a unique data source for the JdbcCursorItemReader and or writer instead of using the default datasource.
If a jdbc-item-reader or jdbc-item-writer data source is not specified the default will be used by the reader or writer.

Updated docs

Updated readme docs
This commit is contained in:
Glenn Renfro
2022-06-15 07:50:14 -04:00
parent 0e56642c53
commit 6029b47592
8 changed files with 343 additions and 25 deletions

View File

@@ -58,7 +58,7 @@ CREATE TABLE IF NOT EXISTS item
```
=== JdbcCursorItemReader with a JdbcItemWriter batch job
In this example the batch job will read from the `item_sample` table in your data store and write the result to the `item` table in your data store.
In this example the batch job will read from the `item_sample` table in your data store (as specified in the default `DataSource` properties) and write the result to the `item` table in your data store (as specified in the default `DataSource` properties).
```
java -Dspring.profiles.active=jdbcreader,jdbcwriter -jar target/single-step-batch-job-2.3.0-SNAPSHOT.jar
```
@@ -82,6 +82,22 @@ INSERT INTO item_sample (item_name) VALUES ('qux');
INSERT INTO item_sample (item_name) VALUES ('Job');
```
You may also wish to read from and write to data sources different from the default `DataSource`. This can be done specifying datasources for the reader and writer as follows:
```
# Jdbc Cursor Item Reader Data Source
export jdbccursoritemreader_datasource_url=<your reader database>
export jdbccursoritemreader_datasource_username=<your user>
export jdbccursoritemreader_datasource_password=<your password>
export jdbccursoritemreader_datasource_driverClassName=<your driver classname>
export spring_batch_job_jdbccursoritemreader_datasource_enable=true
# Jdbc Batch Item Writer Data Source
export jdbcbatchitemwriter_datasource_url=<your writer database>
export jdbcbatchitemwriter_datasource_username=<your user>
export jdbcbatchitemwriter_datasource_password=<your password>
export jdbcbatchitemwriter_datasource_driverClassName=<your driver classname>
export spring_batch_job_jdbcbatchitemwriter_datasource_enable=true
```
=== JdbcCursorItemReader with FlatfileItemWriter batch job
In this example the batch job will read from the `item_sample` table in your data store and write the result to the `result.txt` file to the root directory of the project.
```