I am using spring jdbctemplate to interact with Oracle database. For fetching multiple rows for a given condition, I want to store the result in a csv file having Column names as the header.
I tried few ways -
In customizedrowmapper, I am fetching the rows from result set and setting the fields in Bean class. I could not find any easy way to convert from bean to csv file. As I dont have access to bean class code.
2nd way I found was to writer ResultSet directly to csv file like below using opencsv library.
This is working okay, but it is skipping one row while writing to csv. I tried few queries. Manually, I can see 4 rows in the result, but in the CSV, it stores only three rows. Anyone faced a similar issue?
Or any other way we can achieve the same, without manually getting each record from ResultSet and making it comma-separated
string and storing in file.