permaculture playing cards*
The moose likes JDBC 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
Bookmark "save query result" Watch "save query result" New topic
Author

save query result

Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
Hi,
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.
Jamie
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: save query result
 
Similar Threads
write and read Excel File
SQL Query
Storing the ResultSet
need the HTML source code..
When Session Closed Data Will be Lost in Hibernate