pg_dump from Java - Mailing list pgsql-jdbc

From Michael Schmidt
Subject pg_dump from Java
Date
Msg-id BAY101-DAV15F7E75D5161AF413C8870A3CF0@phx.gbl
Whole thread Raw
List pgsql-jdbc
OK, I'm stumped.  I've been working on this for a couple of days and not found a solution.  I hope someone on this list can set me straight.
 
I'm developing an Eclipse RCP application and have set up a job that runs the backup/restore in a non-UI thread.  There is a runtime process that works (I can get output from command line "pg_dump.exe --help").  The problem is when I try to actually do a dump and use a password.  Of course, one can't put the password on the command line, but rather has to provide it when pg_dump issues a "Password: " prompt.  If the process is started and then the password is simply entered via an OutputStreamWriter like so:
    stdoutWriter.write("password\n".getBytes());
it works.  But this seems "brute force" and doesn't allow for possible delays in getting the Password: prompt from pg_dump.  Better would be to catch the Password: prompt and then provide the password (I want to avoid deadlocks, etc.).  I've attached BufferedReaders to process.getInputStream(), process.getErrorStream() and System.in.  For all three, reader.ready() tests return false. 
 
So, here's the question.  How, exactly, do you test whether pg_dump has issued the Password: prompt?  It doesn't seem to be on any of the streams.  Once I have this, the rest of the code is pretty easy.
 
Thanks!
 
Michael Schmidt

pgsql-jdbc by date:

Previous
From: Pavan Kumar
Date:
Subject: Re: thread hang on execute call
Next
From: Heikki Linnakangas
Date:
Subject: Re: PostgreSQL (XADataSource) as Tomcat Resource