• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Execute pg_dump from within web app

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
guys,

i am trying to implement a database backup functionality from within my web app. now in order to run pg_dump I am using the Runtime functions.

now so far I have got this but its not working,
Process p = Runtime.getRuntime().exec( new String[] {
"cmd.exe",
"/E:1900",
"/C",
"C:/Program Files/PostgreSQL/8.1/bin/pg_dump.exe -i -h localhost -p 5432 -U postgres -F t -b -v -f C:/test.backup TESTDB"});

can somebody help me out. thanks.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you expand a little on 'its not working' ?

You might want to look at the Process.getInputStream() and Process.getErrorStream() methods. These will let you see any output from your program.
 
Pete Dawn
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if i execute this code, it executes without any error but nothing happens. i think that the code is running into an error, which i am trying to catch using getErrorStream().

But perhaps it would be quicker if somebody could tell me if my syntax is correct in the first place, I have a feeling that my syntax is wrong.

Please help. Thanks.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are not even sure the command works you should try it in a command prompt first. Once you have it working, then try calling it from a Java program.
 
Pete Dawn
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the command works fine when i execute it from the command prompt and it performs the backup. but i am not sure of whats the best way of running the same command from within my java code. so the command is correct, but the syntax from within java code is incorrect. any help guys.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well if you only want help from guys, then I guess I'd best drop out of the conversation

Seriously though, the first thing I'd try is to change all the '/' characters in your path names to '\'. Don't forget to escape them.
i.e.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic