pg_dump in PostgreSQL version 8.2 not working in Java app

From: "Michael Schmidt" <michaelmschmidt(at)msn(dot)com>
To: "PostgreSQL JDBC" <pgsql-jdbc(at)postgresql(dot)org>
Subject: pg_dump in PostgreSQL version 8.2 not working in Java app
Date: 2007-01-20 22:21:53
Message-ID: BAY114-DAV114EEFC7F6023D640831B4A3A80@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Folks,
I have an eclipse rcp application that includes backup capability by invoking pg_dump via Java ProcessBuilder. This has been working fine with PostgreSQL 8.1 but quit working when I upgraded to 8.2. Nothing else has changed.

The parameters I pass to the ProcessBuilder via a String Array in my test case are:
[C:\Program Files\PostgreSQL\8.2\bin\pg_dump.exe, --host=localhost, --port=5432, -Upostgres, -W, --verbose, --format=custom, --file=E:\Backup\PostgreSQL\test.bak, npbase]

I've concatenated these parameters into a string and run it from the Command Prompt it works fine except, of course, you have to put "" around C:\Program_Files\...\pg_dump.exe.

The following snippet creates and starts the ProcessBuilder:
ProcessBuilder pb = new ProcessBuilder(cmdParms);
mainProc = pb.start();
// Put a buffered reader on stderr, where the PostgreSQL log is output
procReader = new BufferedReader(new InputStreamReader(mainProc.getErrorStream()));
// Set up a writer to output the password.
procWriter = new PrintWriter(mainProc.getOutputStream());

I then call a method that waits for the password: prompt by reading from the procReader and appending a StringBuffer. When password: is received, it sends the password.
do {
tempInt = procReader.read();
tempSB.append((char) tempInt);
if (-1 != tempSB.indexOf("Password: ")) {
procWriter.println(pwString);
procWriter.flush();
break;
}
} while (procReader.ready());

With 8.2, this job now hangs. I've spent several hours debugging and have found the following. First, pb.start() does not throw an exception, so it appears to be finding pg_dump.exe and trying to start it. It appears that procReader().lready() is always false and that the hang occurs in the do() loop.

Again, all of this worked fine with 8.1. Has something changed with pg_dump?

Michael Schmidt

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2007-01-21 05:10:09 Re: Max size for bytea type
Previous Message Dave Cramer 2007-01-20 18:06:28 Re: Synthesize support for Statement.getGeneratedKeys()?