Java: Drop the. bat file that executes the SQL script
Java drop. bat file
SQL scripts are stored in D: sqlplustest. SQL
Insert into ss values (11 );
Insert into ss values (12 );
Insert into ss values (13 );
Commit;
Exit;
SQL. bat script
@ ECHO OFF
Sqlplus-s username/password @ sid @ D: sqlplustest. SQL
Exit
Java code
Package com. tdxx. sqlplus;
Import java. io. IOException;
Public class ExecComm {
Public static void main (String [] args ){
System. out. println ("start execution .");
RunBat ();
}
Public static void runBat (){
Runtime rt = Runtime. getRuntime ();
Process ps = null;
Try {
Ps = rt.exe c ("cmd.exe/C start/B D: sqlplussql. bat ");
Ps. waitFor ();
} Catch (InterruptedException e ){
E. printStackTrace ();
} Catch (IOException e1 ){
E1.printStackTrace ();
}
Int I = ps. exitValue ();
If (I = 0 ){
System. out. println ("execution completed .");
} Else {
System. out. println ("execution failed .");
}
}
}