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

From: "Michael Swierczek" <mike(dot)swierczek(at)gmail(dot)com>
To: "Damian C" <jamianb(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Novice! How to run pg_dump from within Java?
Date: 2006-07-27 13:08:11
Message-ID: 68b5b5880607270608l72f78cebo138dc268d8a5a6eb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> 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
>

Damian,
Congratulations on figuring it out. The code snippet I sent may
have caught the error, had you used it. I think you would have
gotten a "password for user pgsuperuser:" in the output stream, just
as if you had run that pg_dump command inside windows cmd.exe or a
Linux shell without setting PGPASSWORD.

-Mike

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Sue Fitt 2006-07-27 16:25:58 Re: pg_dump ordering in 8.1.3
Previous Message Tom Lane 2006-07-27 12:56:34 Re: pg_dump ordering in 8.1.3