I am using Apache Tomcat5.0, And Mysql5 .
In my web application I want to generate the primary keys.
I am using
jsp and
servlets technologies.
Just now I have designed it as follow
While creating new record I am fetching the max(id) from the corresponding table
Incrementing the value by one and adding in into create query.
This entire code I am writting in a 'synchronized' block to avoid concurrency.
Please let me know any disadvantages of such method, and if there is any better solution for it without using any third party jars.
Or if no, then please suggest me the better third party jar to generate the keys from servlet.