[英]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()方法可以编写查询以使用全局变量来获取记录。
使用写入Map
的RowMapper
并将Map
用作返回的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.