Urgent: Creating auto increment numbers in JAVA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crazy123
    New Member
    • Feb 2007
    • 2

    Urgent: Creating auto increment numbers in JAVA

    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
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by crazy123
    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.

    Comment

    • crazy123
      New Member
      • Feb 2007
      • 2

      #3
      Originally posted by r035198x
      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...

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by crazy123
        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.

        Comment

        Working...