Re: Novice! How to run pg_dump from within Java?

From: "Damian C" <jamianb(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Novice! How to run pg_dump from within Java?
Date: 2006-07-27 00:50:36
Message-ID: 2bbc8f530607261750o70141f8cv664cca2fa0d26e7e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 7/26/06, Michael Swierczek <mike(dot)swierczek(at)gmail(dot)com> wrote:
> Damian,
> I have a simple in-house application to do this. The code is
> ugly, but it's all I need to get the job done. I've pasted a few
> snippets below. You can use that to capture any messages that
> pg_dump would otherwise print to the screen, to see what the problem
> is.

Michael,
Thanks very much for your response. I actually didn't need it to solve
the issue, but no doubt I will be using your suggested technique
extensively as we move towards production-ready status. Thanks.

Just to record the answer for future googlers!!! Here is how I got it
to work ...
Firstly - refer to my previous post that has the "nearly working" code snip.
The issue was a missing password. The arguments that are passed to the
pg_dump have plenty of information (username, host, port, etc), but no
password. So when invoking the process I set a password into the
PGPASSWORD environment variable as follows...
<snip>
ProcessBuilder pb = new ProcessBuilder(cmds);
Map<String, String> env = pb.environment();
env.put("PGPASSWORD", "my-pg-password-goes-here");
Process process = pb.start();
</snip>

Obviously the above solution is brutal and not-production-ready, but
it did confirm the issue.
Setting PGPASSWORD environment variable is NOT the recommended
technique (see http://www.postgresql.org/docs/8.1/interactive/libpq-envars.html)

Many thanks,
-Damian

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Sean Davis 2006-07-27 01:00:01 Re: Lurking Wanna Be
Previous Message Glenn Davy 2006-07-27 00:37:15 Re: Lurking Wanna Be