View Single Post

   
  #2 (permalink)  
Old 04-16-2008, 01:32 AM
Michael Schmidt
 
Posts: n/a
Default Re: pg_dump in PostgreSQL version 8.2 not working in Java app

Folks,
I've continued working on this problem and the plot thickens. I'm not even able to get output from psql.exe through Java. I ran the following simple test code:

// String[] parms = new String[] {"C:\\Windows\\System32\\ipconfig.exe", ""};
String[] parms = new String[]{"C:\\Program Files\\PostgreSQL\\8.2\\bin\\psql.exe","-Upostgres"};
File f = new File(parms[0]);
if (!f.isFile()) {
System.out.println("Error - this isn't a file");
}
ProcessBuilder pb = new ProcessBuilder(parms);
pb.redirectErrorStream(true);
Process p = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
System.out.println("Exit with " + p.exitValue());

The ipconfig utility simply outputs the internet configuration. I used the "" String to simulate a parameter. This code identifies parm[0] as a valid file, outputs the configuration, and returns an exit code of 0, as it should. When I switch the parms (comment out the ipconfig String[] line and remove the comments from the psql.exe String[] line), the process hangs. So, with identical code, ipconfig works and psql hangs. What the hey? And again, this did not happen with 8.1.

Michael Schmidt
Reply With Quote