Hi,
i have a scenario like this, my requirement is i get the next number(primary key) of a table before insertion a new record. I am using oracle database, so there no need to put auto increament option.
I have two possibilities,
1. write a sequence and get sequence.nextval to get the next number
2. Write a
java code for getting the next number.
For this, i count the no of the records of the table and increament by 1. But the problem , when multiple users request the same page, there may be a chance to get primary key voilation.
Otherwise, my method is set to be synchorized, but it is a performance problem.
So, please tell me what is the best solution for this scenario.
Thanks
Pavan