本文整理汇总了Java中org.springframework.batch.item.database.JdbcBatchItemWriter类的典型用法代码示例。如果您正苦于以下问题:Java JdbcBatchItemWriter类的具体用法?Java JdbcBatchItemWriter怎么用?Java JdbcBatchItemWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JdbcBatchItemWriter类属于org.springframework.batch.item.database包,在下文中一共展示了JdbcBatchItemWriter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: customerItemWriter
import org.springframework.batch.item.database.JdbcBatchItemWriter; //导入依赖的package包/类
@Bean
@StepScope
public JdbcBatchItemWriter<Customer> customerItemWriter() {
JdbcBatchItemWriter<Customer> itemWriter = new JdbcBatchItemWriter<>();
itemWriter.setDataSource(this.dataSource);
itemWriter.setSql("INSERT INTO NEW_CUSTOMER VALUES (:id, :firstName, :lastName, :birthdate)");
itemWriter.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider());
itemWriter.afterPropertiesSet();
return itemWriter;
}
示例2: personEtl
import org.springframework.batch.item.database.JdbcBatchItemWriter; //导入依赖的package包/类
@Bean
Job personEtl(JobBuilderFactory jobBuilderFactory,
StepBuilderFactory stepBuilderFactory,
FlatFileItemReader<Person> reader,
JdbcBatchItemWriter<Person> writer
) {
Step step = stepBuilderFactory.get("file-to-database")
.<Person, Person>chunk(5)
.reader(reader)
.writer(writer)
.build();
return jobBuilderFactory.get("etl")
.start(step)
.build();
}
示例3: jdbcBatchItemWriter
import org.springframework.batch.item.database.JdbcBatchItemWriter; //导入依赖的package包/类
@Bean
JdbcBatchItemWriter<Person> jdbcBatchItemWriter(DataSource h2) {
JdbcBatchItemWriter<Person> w = new JdbcBatchItemWriter<>();
w.setDataSource(h2);
w.setSql("insert into PEOPLE( first, last, email) values ( :first, :last, :email )");
w.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>());
return w;
}
示例4: jdbcBatchItemWriter
import org.springframework.batch.item.database.JdbcBatchItemWriter; //导入依赖的package包/类
@Bean
public JdbcBatchItemWriter<Item> jdbcBatchItemWriter(){
JdbcBatchItemWriter<Item> itemWriter = new JdbcBatchItemWriter<Item>();
itemWriter.setSql("INSERT INTO ITEM (ID, DESCRIPTION) VALUES (:id,:description)");
itemWriter.setDataSource(dataSource);
itemWriter.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Item>());
return itemWriter;
}
开发者ID:codecentric,项目名称:spring-boot-starter-batch-web,代码行数:9,代码来源:FlatFileToDbSkipReaderTransactionalJobConfiguration.java
示例5: writer
import org.springframework.batch.item.database.JdbcBatchItemWriter; //导入依赖的package包/类
@Bean(name = readCsvFileIntoTableStepWriter)
public JdbcBatchItemWriter<Customer> writer(DataSource dataSource) throws Exception {
JdbcBatchItemWriter<Customer> jdbcBatchItemWriter = new JdbcBatchItemWriter<Customer>();
jdbcBatchItemWriter.setAssertUpdates(true);
jdbcBatchItemWriter.setDataSource(dataSource);
jdbcBatchItemWriter.setSql(" INSERT INTO customer( first_name, last_name) VALUES ( :firstName , :lastName ) ");
jdbcBatchItemWriter.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Customer>());
return jdbcBatchItemWriter;
}
示例6: productItemWriter
import org.springframework.batch.item.database.JdbcBatchItemWriter; //导入依赖的package包/类
@Bean
public ItemWriter<Product> productItemWriter() {
JdbcBatchItemWriter<Product> itemWriter = new JdbcBatchItemWriter<Product>();
itemWriter.setDataSource(dataSource);
itemWriter.setSql("insert into product (id, name, description, price) values(?,?,?,?)");
itemWriter.setItemPreparedStatementSetter(new ProductPrepareStatementSetter());
itemWriter.afterPropertiesSet();
return itemWriter;
}
示例7: dbWriter
import org.springframework.batch.item.database.JdbcBatchItemWriter; //导入依赖的package包/类
@Bean
public ItemWriter<Person> dbWriter() {
JdbcBatchItemWriter<Person> writer = new JdbcBatchItemWriter<>();
writer.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Person>());
writer.setSql("INSERT INTO person (login, passwd, age) VALUES (:login,:passwd,:age)");
writer.setDataSource(dataSource);
return writer;
}
示例8: jdbcWriter
import org.springframework.batch.item.database.JdbcBatchItemWriter; //导入依赖的package包/类
@Bean
ItemWriter<Map<String, Object>> jdbcWriter(@Qualifier("exportDataSource") DataSource exportDataSource) {
JdbcBatchItemWriter<Map<String, Object>> writer = new JdbcBatchItemWriter<>();
writer.setDataSource(exportDataSource);
writer.setSql("INSERT INTO twitter_influencers (user_name, followers) VALUES (:user_name, :followers)");
return writer;
}
示例9: jdbcBatchItemWriter
import org.springframework.batch.item.database.JdbcBatchItemWriter; //导入依赖的package包/类
@Bean
public JdbcBatchItemWriter<Item> jdbcBatchItemWriter(){
JdbcBatchItemWriter<Item> itemWriter = new JdbcBatchItemWriter<Item>();
itemWriter.setSql("INSERT INTO ITEM (ID, DESCRIPTION, FIRST_ACTION, SECOND_ACTION) VALUES (:id,:description,:firstAction,:secondAction)");
itemWriter.setDataSource(dataSource);
itemWriter.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Item>());
return itemWriter;
}
开发者ID:codecentric,项目名称:spring-boot-starter-batch-web,代码行数:9,代码来源:FlatFileToDbNoSkipJobConfiguration.java