How to execute CMD line when Java prompts for password

HY,

I tried to dump the PostgreSQL database from my java application

It is OK in CMD:

pg_dump -U user database>outfile.sql

And CMD prompt for password

To access this command line from my Java:

Runtime.getRuntime().exec("pg_dump -U user database>outfile.sql");

Now it waits for the password

I try to use runtime getRuntime(). Exec (string [])... But not

Somehow, I have to be here Set the parameter 'password' in the exec () method,

pg_ Dump statement does not accept passwords on the command line

Solution

Press enter when missing

bw.write("password" + "\n");
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>