简体   繁体   English

从数据库读取批量数据(动态查询),并使用spring batch将其写入平面文件

[英]Read bulk data (Dynamic query) from Database and write to flat file using spring batch

I want to read a bulk data from database, the query to read the tables will be dynamic (table name will be chosen from the config file). 我想从数据库中读取大量数据,读取表的查询将是动态的(表名称将从配置文件中选择)。 and wite the data in a flatfile with a delimiter. 并在带有分隔符的平面文件中写入数据。 As the table name itself dynamic, I cant go with any rowmapper/DTO/VO classes. 由于表名本身是动态的,因此我无法使用任何rowmapper / DTO / VO类。

Which is reading a custom data and writing it to the flat file with some delimiter. 它正在读取自定义数据,并使用一些定界符将其写入平面文件。

Can you help to identify how we can achieve this with spring batch. 您能帮助确定我们如何通过春季批处理实现这一目标。

Write your custom reader implementing ItemStreamReader. 编写实现ItemStreamReader的自定义阅读器。 Read the config file in the open() method and set the table name as a global variable. 在open()方法中读取配置文件,并将表名设置为全局变量。 read() method you can write the query to fetch the record using the global variable. 使用read()方法可以编写查询以使用全局变量来获取记录。

使用写入MapRowMapper并将Map用作返回的项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Spring Batch读写zOS(Mainframe)平面文件 - How to Read/write zOS(Mainframe) flat file using spring batch 如何使用 Spring Data Cassandra 从 cassandra 数据库读取超过百万条记录并使用 Spring Batch 将其写入文件? - How to read more than million records from cassandra Database using Spring Data Cassandra and write it into a file using Spring Batch? 从文件(XML / Flat / CSV)中读取批量数据,并将数据上传到数据库中 - Read bulk data from file (XML/Flat/CSV) and upload data in database 使用Spring批处理读取文件并写入Map - Using Spring batch to read a file and write to a Map Spring Batch如何读取多个表(查询)作为Reader并将其写为平面文件写入 - Spring Batch How to read multiple table (queries) as Reader and write it as flat file write 从平面文件读取数据并将其写入xml的最佳方法 - best way to read data from flat file and write it to xml 从列表中读取数据并创建字符串以写入平面文件 - read data from list and create string to write flat file Spring Batch - 从 FlatFile 读取写入有效到数据库和无效到 FlatFile - Spring Batch - Read from FlatFile write Valid into Database and Invalid into FlatFile 使用多线程从数据库读取数据并写入文件 - Read data from database and write into file using multithreading 设计一个 Spring 批处理应用程序来读取不同资源的数据(平面文件) - Design a Spring batch application to read data from different resources(Flat files)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM