Reputation: 39
Can I include the password to my psql command?
My command is:
psql -h localhost -p 5432 -U mee -d my_db -f sqltest.sql
because I'm trying to run it through my java application but i didn't know how to specify it.
Process pro = Runtime.getRuntime().exec("psql -h localhost -p 5432 -U mee -d my_db -f sqltest.sql");
BufferedReader br = new BufferedReader(new InputStreamReader(pro.getInputStream()));
String line;
while ((line = br.readLine()) != null)
System.out.println("heeeeeeeeeeere : "+line);
Upvotes: 0
Views: 2240
Reputation: 1081
The most you can do is save the password for the user you are connecting through in .pgpass
file - located in a user's home directory. This way psql will not ask for the password. There is no way to pass password as an argument with psql.
Upvotes: 2