*
The moose likes Beginning Java and the fly likes item ID numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "item ID numbers" Watch "item ID numbers" New topic
Author

item ID numbers

Nicholas Lefebvre
Greenhorn

Joined: Feb 05, 2013
Posts: 23
I need to make a program that can aoutomaticaly create and asign a ID number to a new item but the ID number can not be repeated once. How would i do that the rest of the program is working i just need to genereate it.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Depending on your id requirement, you can consider AtomicInteger, AtomicLong or UUID


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7677
    
  19

Nicholas Lefebvre wrote:I need to make a program that can aoutomaticaly create and asign a ID number to a new item but the ID number can not be repeated once. How would i do that the rest of the program is working i just need to genereate it.

My advice: Use a database.

Chances are that your Item will have to be stored somewhere anyway, so why not use the place where you're going to store it?

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Nicholas Lefebvre
Greenhorn

Joined: Feb 05, 2013
Posts: 23
I dont know how to start setting up the database but i do know how to start the data base is access but MySQL and that i dont know.So could you tell me the steps involved.
egbai mmumene
Ranch Hand

Joined: Sep 18, 2012
Posts: 43
create a java class containing the jdbc mysql class objects there you define your database name and password. but before that you need to download the plugin and extract it into your jar file library.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: item ID numbers