export CSV file through Java JDBC - Mailing list pgsql-sql

From Emi Lu
Subject export CSV file through Java JDBC
Date
Msg-id 48035F15.4030302@encs.concordia.ca
Whole thread Raw
List pgsql-sql
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("execcommand 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!




pgsql-sql by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: Get the last inserted id
Next
From: "Chad Showalter"
Date:
Subject: rule for update view that updates/inserts into 2 tables