Use the throw, try... catch, finally, and retry to generate and handle exceptions.
In transaction
developments(ttsbegin/ttscommit),use the exception presented below:
·
Deadlock - Handling for deadlocks in the database. The deadlock occurs when multiple transactions are waiting for
each other.
·
UpdateConflict - Handling for UpdateSConflicts. The update
conflict occurs when a transaction is
using OCC (Optimistic Concurrence Control). The transaction can be repeated.
· DuplicateKeyException - Handling for duplicate key field conflicts. Duplicity occurs when a transaction is using Optimistic Concurrence Control (OCC). The transaction can be repeated.
#OCCRetryCount
try
{
ttsbegin;
Your code
here
ttscommit;
}
catch (Exception: :D eadlock)
{
Retry on
deadlock
retry;
}
catch (Exception::UpdateConflict)
{
Retry to
resolve conflict update
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount()
>= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
catch(Exception: :D
uplicateKeyException)
{
Retry in
case of a duplicate key conflict
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount()
>= #RetryNum)
{
throw Exception::D uplicateKeyExceptionNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::D
uplicateKeyException;
}
}
Hope you find this useful, I will come up
with another interesting blog post.
Great content and very helpful explanation. I really enjoyed reading this. You can also check AI powered Core JAVA Online Training.
ReplyDeleteGreat article with simple and clear explanation. This kind of content is really valuable. For more insights, visit AI powered Core JAVA Online Training.
ReplyDeleteGreat explanation and very informative content. It helped me understand the topic better. You can also explore AI powered Core JAVA Online Training.
ReplyDelete