May 2015
Intermediate to advanced
234 pages
4h 18m
English
This recipe shows you how to read data from a database as part of a read/process/write step.
Each user will be read from the database. Make sure that the user database table exists with some data in it:
CREATE TABLE user (
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
first_name TEXT,
age INT
);For each user row in the database, we'll create a User object. Make sure that the User class exists:
public class User {
private String firstName;
private int age;Make sure that the Datasource bean is defined with the database connection information.
Add a reader() method returning JdbcCursorItemReader-a class provided by Spring Batch:
@Bean @StepScope public JdbcCursorItemReader<User> reader() { JdbcCursorItemReader<User> ...Read now
Unlock full access