This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes save query result Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "save query result" Watch "save query result" New topic

save query result

Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
Does someone know how to programmatically save a query result as text file or excel file?

Thanks,<br />Mike
Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 265
Using files concept u can save the results as text files.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

This should do what you want:
Assume the resultset has 5 columns:

NOTE: files with the extension *.csv default to open in Microsoft Excel, unless manually change by the user's settings. *.csv files represent comma delimited files in which each column value is separated by a comma. Each row is separated by a newline character which is automatically added when using the println method of PrintWriter.
I agree. Here's the link:
subject: save query result
It's not a secret anymore!