It is possible to method to instantly put multiple updates into batches? For instance, transform the program:

PreparedStatement prepStmt = con.prepareStatement("UPDATE DEPT SET MGRNO=? WHERE DEPTNO=?");            
prepStmt.setString(1,mgrnum1);                          
prepStmt.setString(2,deptnum1);
prepStmt.executeUpdate();                                    

prepStmt.setString(1,mgrnum2);                        
prepStmt.setString(2,deptnum2);
prepStmt.executeUpdate();

con.commit();       

into the program:

connection con.setAutoCommit(false);                  
PreparedStatement prepStmt = con.prepareStatement(    
  "UPDATE DEPT SET MGRNO=? WHERE DEPTNO=?");            
prepStmt.setString(1,mgrnum1);                          
prepStmt.setString(2,deptnum1);
prepStmt.addBatch();                                    

prepStmt.setString(1,mgrnum2);                        
prepStmt.setString(2,deptnum2);
prepStmt.addBatch();
int [] numUpdates=prepStmt.executeBatch();              
for (int i=0; i < numUpdates.length; i++) {             
  if (numUpdates[i] == -2)
    System.out.println("Execution " + i + 
      ": unknown number of rows updated");
  else
    System.out.println("Execution " + i + 
      "successful: " numUpdates[i] + " rows updated");
}
con.commit();

Could this modification be carried out by a compiler instantly? What work continues to be done about this?

Thanks, a database noob.

A compiler could do that transformation however i know no compiler that does.

Potentially you could utilize (or code yourself) something similar to Spring's JDBCTemplate to ensure you get templated behavior (for example commit in the finish of some batches), but as @Peter G. states it isn't the compiler that will do instantly do that, it is your (or a 3rd party) code.

AOP is yet another option here if you are really searching to implement this.