I am developing billing software in java. In my application user opens a window for creating an invoice.
When the window opens it fetchs the MaxID
and returns a long
MaxID+1
from the INVOICE
table and displays it in a Jlabel
. Now when user starts billing everytime the invoice number will be MaxID+1
. This system runs fine in single user application.
But when this application runs in multiple computer a great issue happens. When Two users, say, userOne
and userTwo
opens the same window at the same time they will get the same MaxID+1
. and as a result Both of them will enter data in the same invoice number. How can I resolve this?
Please help.