pg_dump from Java

From: "Michael Schmidt" <michaelmschmidt(at)msn(dot)com>
To: "PostgreSQL JDBC" <pgsql-jdbc(at)postgresql(dot)org>
Subject: pg_dump from Java
Date: 2006-04-09 00:07:25
Message-ID: BAY101-DAV15F7E75D5161AF413C8870A3CF0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-jdbc by date

  From Date Subject
Next Message Heikki Linnakangas 2006-04-09 08:50:24 Re: PostgreSQL (XADataSource) as Tomcat Resource
Previous Message Pavan Kumar 2006-04-07 12:09:45 Re: thread hang on execute call