How can I save ResultSet to the file

M

Marzena

Hi,
Does anybody know how can I save ResulSet from database to the file ??
I m making application i need to make raport of the things from
database... i was looking in the internet but there is no tip how to
do it...Tnx for any help.
 
L

Lord Zoltar

Hi,
Does anybody know how can I save ResulSet from database to the file ??
I m making application i need to make raport of the things from
database... i was looking in the internet but there is no tip how to
do it...Tnx for any help.

There's MANY ways to do it. In my opinion, the easiest way would be to
write a saveToFile method that will write a ResultSet to a CSV (Comma
Seperated Value) file, which is usually an easy job. Of course, this
only works if your reporting software can handle CSV. Excel can handle
it easily, and other reporting tools also usually have some facility
for CSV import.
Without knowing anything about your reporting needs, I can't really
say too much else.
 
M

Marzena

How exactly do i need to do that?
Put all resultset into array and save it in to the file manualy?

or maybe there is any faster way to put directly resultsSet to the
file?
 
L

Lord Zoltar

How exactly do i need to do that?
Put all resultset into array and save it in to the file manualy?

or maybe there is any faster way to put directly resultsSet to the
file?

you could use an N x M array (N is number of items in each row, M is
number of rows), and then write each row to a line in the file, with
each item in each row seperated by a comma (or other delimiting
character).

Serializing the ResultSet object directly to file as a binary object
MIGHT be faster, but it's not very portable (and I don't even know if
it would work - I've never tried anything like this). If this is
possible, and speed is more important than portability, then yeah
sure, go this road.
 
R

Roedy Green

How exactly do i need to do that?
Put all resultset into array and save it in to the file manualy?

See http://mindprod.com/jgloss/csv.html

Retrieve the records, dump them in a CSV file.
You can run it on a client if the set is small or on the server if it
is large.

Your database also likely has an export feature you trigger from the
command line. Some dump in a format similar to CSV except it uses '
instead of " as the delimiter.
I wrote a CSV reader that can handle it.
see http://mindprod.com/jgloss/csv.html
 
R

Roedy Green

Serializing the ResultSet object directly to file as a binary object

That would not work. The ResultSet is lives only in the context of a
connection. you could though serialise the individual fields. If you
had some sort of database interface that handed you complete objects,
one per row, you could serialise them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top