'What is a transaction? - 08.08.2001

Julien SIMON



A transaction is a set of modifications performed atomically, which means that either all modifications are performed or none are performed. This is particularly for smart cards, because the card reader powers them: when you unexpectedly remove the card from the reader (this is called "tearing"), it's possible that you're interrupting a critical operation that needed to run to completion. This could put the card in an irrecoverable state and make it unusable.

To prevent this, the Java Card platform offers a transaction mechanism, through which the developer may declare a set of modification as being part of a same transaction. If the transaction completes normally, then all writes are committed. If the transaction is interrupted (power loss, application error, etc), previous writes will be undone automatically when the card is next powered up. The transaction API is defined in javacard.framework.JCSystem.