I want to write the result of an sql query to a csv or excel file and save it in a particular folder.I would like to know if this can be achieved using a java program which can be reused for any sql query result.I would also like to know if this can be used for different types of databases(oracle,mysql,MS sql server etc).I plan to attach the saved file to an email(is this possible directly exporting a sql query result to an email).Please help.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- How to maintain order of key-value in DataFrame sa
Simplest solution.
Main Method
fetchDataFromDatabase
The code below count the number of columns in a table, and store in a result array.
printToCsv
With use of openCSV API, you can export your data in csv file.
Here is an example:
Reference