File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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!