Hello,I am making a website in JSP celled employee info system.In this whenever a new emp. registers in the system he is given a unique employee id. Currently in my registration page the employee himself will have to manually enter a unique id.Is there a way in which the unique id is generated serially and dynamically .How to do this.Please help.

Recommended Answers

All 7 Replies

Perhaps you will find more help in the JSP forum :)

Why you are making more difficult to your self? Why do you not let a user fill in registration form and then on successful submit let him/her know what was auto-generated id in the table?

ok.My question will still be the same.How do I generate the unique id.say if 1st user's id is 1001.how do i generate 1002 as soon as a new employee registers and show him that this is his id.

When you are declaring your tables you need to use AUTO_INCRMENT for MySQL for example or sequence (seq) for PostgreSQL. You would find similar mechanisms for any database. If you have problem find it, just let us know what DB you are using

yeah I just came across that.But in auto increment the values start from 1.Is there a way to change it to make it count from 1001? or maybe ER1001 then ER1002 etc .thanks anyway.

Read documentation it does tell you have to set starting value...
As for chance to do combination of character plus number, that is not possible and have to be done programatically, meaning you retrieve ID and prefix it what ever you need and then show it to user

Thanks for the info...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.