By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,787 Members | 2,251 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,787 IT Pros & Developers. It's quick & easy.

Urgent: Creating auto increment numbers in JAVA

P: 2
Please guide me as how do can we create a aut generated number...

I have created a database. I am giving each name in the database entry a unique ID

I want the Unique ID to be auto generated when I want to add an entry in the database in an increment fashion

Do let me know ur views and the code that works...I m in urgent need of it...........

thanks a lot
Feb 3 '07 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
Please guide me as how do can we create a aut generated number...

I have created a database. I am giving each name in the database entry a unique ID

I want the Unique ID to be auto generated when I want to add an entry in the database in an increment fashion

Do let me know ur views and the code that works...I m in urgent need of it...........

thanks a lot
If you want to do this manually you can use another table to stores the current reference number and write a static method in some utility calss that generates a referenceNumber by incrementing the value of this field and returning the result.
Feb 3 '07 #2

P: 2
If you want to do this manually you can use another table to stores the current reference number and write a static method in some utility calss that generates a referenceNumber by incrementing the value of this field and returning the result.





Thanks for the reply but I m not very clear about storing the current reference number in another table, as we have name only name as a reference .....and a unique ID against it to distinguish ...which (the unique id ) I want to be auto generated...
Feb 3 '07 #3

10K+
P: 13,264
Thanks for the reply but I m not very clear about storing the current reference number in another table, as we have name only name as a reference .....and a unique ID against it to distinguish ...which (the unique id ) I want to be auto generated...
You can use the same table if you like and add a field for the last generated ref number.When next time you want to create a new entry you check the value of this field, increment it by one and use that for the next id then you set that value as the last generated ref number.
Feb 3 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.