Initially I ran this code without the leading "cmd" and I received an access denied message. Postgres is being run as a service by an account that cannot be logged into and I am an administrator running this application. The attempt with "cmd" included returns me no input. My question is how do I go about executing these statements to achieve the resulting files and data changes?
String[] psqlCommands = {"cmd ",postgresLocation, " -dDatabase ", " -UUser ",
"-c ", "UPDATE host.user SET service = 1 WHERE service = 1;" +
"UPDATE host.permission SET service = 1 WHERE service = 2"};
Runtime.getRuntime().exec(psqlCommands);
String[] pgDumpCommands = {"cmd ", postgresLocation, " --data-only ",
"-t host.user_info -t host.permission -t host.group -t host.account -t host.password " +
"-UUser Database> "
+ DATA + "\\dataExport.sql"};
Runtime.getRuntime().exec(pgDumpCommands);
The exception that is generated is an Access Denied exception that is on the Postgres_Bin directory. I will post a trace once I get the necessary materials.
Exception in thread "main" java.io.IOException: Cannot run program "d:\program f
iles\postgres\bin": CreateProcess error=5, Access is denied
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at Thing.main(Thing.java:85)
Caused by: java.io.IOException: CreateProcess error=5, Access is denied
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 4 more
postgresLocation? Some of the parameters are valid forpsqland others - forpg_dumpbut I can't see where you mention the appropriate tool. But given the "access denied" message I believe you're trying to dump to a directory you have no rights to.