I have an ORACLE SQL sctipt with several queries and tables, and I wan to run that script from my java program at the starting of the program to ensure that everything is on the right place. I found a code to run the script, but it doesn't work for some reason. Can anyone provide me samples so that I can follow it.
This is what I found :
try {
String line;
Process p = Runtime.getRuntime().exec ("psql -U sas -d oracle -h @localhost -f Lab_05_Tables.sql");
BufferedReader input =new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
}
catch (Exception err) {
err.printStackTrace();
}
But it doesn't work though.
Error
java.io.IOException: Cannot run program "psql": CreateProcess error=2, The system
cannot find the file specified
psqlthe PostgreSQL command line? Can it handle Oracle, too?psqlcould not be found. Maybe you need to specify the full path. And it is doubtful if psql can handle Oracle. You probably wantsqlplus.