I am trying to reload a .sql
script file into PostgreSQL from my sample Java application.
Script is successfully executed from console as well as from pgAdmin tool. But from Java, it hangs...
This is the code I am using:
C:/Program Files/PostgreSQL/9.2/bin/psql.exe -U postgres -d sampledb -f "H:/Data/samplescript_postgres.sql"
Can anyone help me? I am using PostgreSQL 9.2
Java code:
String path = "H:/Data/samplescript_postgres.sql";
final String cmd = "C:/Program Files/PostgreSQL/9.2/bin/psql.exe -U postgres -d sampledb -f " + "\""+ path + "\" ";
try {
reloadProcess = Runtime.getRuntime().exec(cmd);
if(null!=reloadProcess){
if(reloadProcess.waitFor()==0){
System.out.println("Reloaded");
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
My pg_hba.conf file:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5