Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id E2F072E0031 for ; Mon, 14 Apr 2008 10:41:54 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 66931-01 for ; Mon, 14 Apr 2008 10:41:39 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from perseverance.services.encs.concordia.ca (perseverance-96.encs.concordia.ca [132.205.96.94]) by developer.postgresql.org (Postfix) with ESMTP id 895632E002F for ; Mon, 14 Apr 2008 10:41:47 -0300 (ADT) Received: from cacao.encs.concordia.ca (emilu@cacao.encs.concordia.ca [132.205.47.225]) by perseverance.services.encs.concordia.ca (envelope-from emilu@encs.concordia.ca) (8.13.7/8.13.7) with ESMTP id m3EDffvA001289 for ; Mon, 14 Apr 2008 09:41:42 -0400 Message-ID: <48035F15.4030302@encs.concordia.ca> Date: Mon, 14 Apr 2008 09:41:41 -0400 From: Emi Lu Reply-To: emilu@encs.concordia.ca User-Agent: Thunderbird 2.0.0.12 (X11/20080213) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: export CSV file through Java JDBC Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.58 on perseverance.encs.concordia.ca at 2008/04/14 09:41:42 EDT X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/81 X-Sequence-Number: 30620 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!