pg_dump in PostgreSQL version 8.2 not working in Java app

Поиск
Список
Период
Сортировка
От Michael Schmidt
Тема pg_dump in PostgreSQL version 8.2 not working in Java app
Дата
Msg-id BAY114-DAV114EEFC7F6023D640831B4A3A80@phx.gbl
обсуждение исходный текст
Список 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

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Synthesize support for Statement.getGeneratedKeys()?
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: Max size for bytea type