Java - general

SQL, commit, rollback

Normally, all SQL-commands are carried out immediatly. If you want to avoid this, „AutoCommit“ must be turned off explicitly:


try {
   // turn off AutoCommit:
   connection.setAutoCommit(false);
 
   // put down divers SQL-commands...
 
   // Until here everything has worked out, so now commit:
   connection.commit();
} catch (SQLException e) {
   // Something went wrong, so revoke everything:
   connection.rollback();
}

Eigene Werkzeuge
Werkzeuge

gratis Counter by GOWEB
seit 9.10.2007