Skip to content
Advertisement

Tag: export-to-csv

Write ResultList from DB into a CSV file in Java

I need to write my query.getResultList() into a .CSV file. I call the query over this: and the Namequery just do SELECT * FROM TABLE, the result of query.getResultList() looks like this: I can’t use OpenCSV. The CSV file needs to have headers. Answer You can use something like

How to process object with map for CSV output

I have a set of below Objects, which i need to write to CSV: Above set can have a map with two, three or four values. Output of CSV required: I started with below snippet to print out: But above is creating a two column csv with userId and behaviours printing all map object behaviours. How to achieve above type

Open CSV to export resultset to string type

I want to export the result set of the SQL query to a CSV file. I am using opencsv to export to CSV file. I am using below code to achieve it. But the problem I face is, it automatically exports to the datatype of the database column which is from resultset. Example: if I a column with datatype as

Advertisement