I have a table, TBLCUSTOMERS that I'd like to dump to a CSV file.
In my code I have an export button that performs the following query :
CALL CSVWRITE('export.csv', 'SELECT * FROM TBLCUSTOMERS');
It runs and returns that 36 records were written to disk. I have not
been able to find the export.csv file anywhere. I've even dumped the
table and created a dummy one, but alas, no joy,
Could someone a lot smarter please point out what I'm doing wrong?
I'm using 1.2.127 (2010-01-15), currently on WinXP, Java 1.6.0_17-b04
Thank you
Ewald
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
> CALL CSVWRITE('export.csv', 'SELECT * FROM TBLCUSTOMERS');
> I have not been able to find the export.csv file anywhere.
It's in the current working directory where the database (server) is running.
Regards,
Thomas
Hi.
Thank you for clearing that up.
I have the server running on a different machine and I access it from
my local machine. Is there no way to have CSVWRITE write to my current
machine?
The CSV export is brilliant and I'd like the client machine to be able
to write out to a CSV file and open it in OpenOffice if possible.
Thank you
Ewald
Hi.
I created a public, shared folder on the server (the smarter security
folks will have a fit) and simply dump the CSV files there. The
application then picks it up from the network, copies it to the local
machine and start up OpenOffice Calc. It might not be the most
elegant solution, but it sure does solve my problem.
Best regards
Ewald
> I have the server running on a different machine and I access it from
> my local machine. Is there no way to have CSVWRITE write to my current
> machine?
SQL statements are executed on the server, and the server doesn't have
access to the file system where the JDBC client runs (this is true for
all databases, not only H2). But you can use the Csv tool directly:
import org.h2.tools.*;
...
ResultSet rs = ...
Csv csv = Csv.getInstance();
csv.write("<path_to_local_file>", rs, "UTF-8");
Please note the default charset for Csv.write is not UTF-8 (the
javadocs are wrong), but the system default charset.
See also http://www.h2database.com/javadoc/org/h2/tools/Csv.html#write_String_ResultSet_String
Regards,
Thomas
Hi Thomas.
Thank you, I missed this in the documentation, and now I feel like an
idiot! I have to tell you, I've confused my IT manager, we have a MS
SQL server installation, not sure which version (I don't touch .Net),
running on a blade, and I do things on my development PC that baffle
them. Running H2 in embedded mode is insanely fast, and even when I
deploy to the network, I still end up running circles around our
"dedicated server". Go figure!
Best regards
Ewald