0

Currently I have my java application running in multiple servers. I have a data transaction which is encountering a deadlock. I tried using thread and synchronization, but in vain, as there are multiple application instances in multiple servers. Each application instance have their data transaction synchronized, but different synchronized application transactions on the same database happens to land the database in a deadlock situation, as for all application instances the database is same and one.

Kindly suggest the right approach in this kind of situation. Any high level solution will also suffice.

sam100rav
  • 3,733
  • 4
  • 27
  • 43

1 Answers1

1

Simply, create table in database as

create table LOCKER(
   NAME VARCHAR2(20) PRIMARY KEY NOT NULL
)

in code use like this idea:

query.run("insert into locker('keyForLock')").flush();
//write your code to here
query.run("delete from locker where name = 'keyForLock'").flush();
utrucceh
  • 1,076
  • 6
  • 11