From: Emi Lu <emilu@encs.concordia.ca>
To: pgsql-sql@postgresql.org
Subject: export CSV file through Java JDBC
Date: Mon, 14 Apr 2008 09:41:41 -0400
Message-ID: <48035F15.4030302@encs.concordia.ca> (raw)
Good morning,
Running the following command from command line is ok, but cannot export
a table into a csv file through java JDBC code.
Please help!
JAVA code:
===================
public static void exec(String command)
{
try{
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
p.destroy();
}catch(Exception e) {
System.err.println("exec command Error: " + e.getMessage());
}
}
SQL Command:
=================
psql -U username -d dbName -c "\copy tableName to 'result.csv' with CSV "
When call exec(commands);
Nothing happens, result.csv was not created at all?
Thanks a lot!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: emilu@encs.concordia.ca
Subject: Re: export CSV file through Java JDBC
In-Reply-To: <48035F15.4030302@encs.concordia.ca>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox