In your code, you run the sqlplus command in a loop, so you must end each command (using exit to exit sqlplus).
If you want to call many scripts in a single sqlplus instance, perhaps you can create an on-the-fly script that has commands such as:
onTheFlyAcript.sql
@createtable.sql <your params> @insertvalue.sql <your params> exit;
So you can do something like:
try { Printwriter out = new PrintWriter(new FileWriter("D:/Test/onTheFlyScript.sql")); for (int i = 0; i<list_files.length;i++){ script_location = "@" + list_files[i].getAbsolutePath(); out.println("START script_location"); } out.close(); } catch (IOException e){ e.printStackTrace(); }
This will probably have to be debugged, but the idea is that instead of executing all your scripts one by one using sqlplus, you create a new script that contains calls to all your scripts.
Now you can remove the exit sqlplus exit from all of your scripts since you do not need to exit sqlplus (only onTheFlyScript.sql)
source share