AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

eindeutige Ids

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language (German)
View previous topic :: View next topic  
Author Message
Gidion
Guest





PostPosted: Fri May 18, 2007 2:01 am    Post subject: eindeutige Ids Reply with quote



HI,

kennt jemand einen guten und sicheren Algorithmus zum erzeugen von
eindeutigen IDs?
wobei die IDs:

a) im Bereich von 19.999 - 1.999.999 liegen und nicht nach einander
hochgezählt werden
b. immer genau 10 Zeichen lang sind.

bisher ist mir nur eine Lösung eingefallen die das so einigermaßen
kann:

es gibt eine DB Tabelle da steht die als erster Wert 19.999 drin.
alle objekte holen sich immer die nächste ID aus dieser Tabelle
dadurch das es alle Objekte machen sind die IDs pro Objekt wenigstens
nicht vortlaufend.

danke.

mfg Gabriel
Back to top
Kai Schwebke
Guest





PostPosted: Fri May 18, 2007 2:27 am    Post subject: Re: eindeutige Ids Reply with quote



wie wär's mit
http://java.sun.com/javase/6/docs/api/java/util/UUID.html

Gruß
Kai
Back to top
Achim Peters
Guest





PostPosted: Sun May 20, 2007 9:27 pm    Post subject: Re: eindeutige Ids Reply with quote



Bernd Eckenfels wrote:
Quote:
Achim Peters <AchimPeters (AT) gmx (DOT) de> wrote:
public class Id {
static int id;
public static int getNextId() {
return id++;
}
}

muss synchronisiert sein - und vermutlich auch persistent.

Wieso? Ich lese beim OP nichts von Multithreading oder Persistenz.

Bye
Achim
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.