File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Unique Key Generation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Unique Key Generation" Watch "Unique Key Generation" New topic

Unique Key Generation

Saidul Islam

Joined: Dec 05, 2000
Posts: 18
Did anyone work on any unique key generation algorithm that is not based on timestamp? Maybe based on the combnation of timestamp and random numbers, or database driven or any other mechanishm.
Would you like to share your thoughts on this?
Forgive me if the question sounds not related to the forum. Maybe we can ask JavaRanch host to create a new forum for discussing algorithm/pattern in Java.

Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Sounds like a good question for this forum.
This is another thread that was discussing random number generation:

"JavaRanch, where the deer and the Certified play" - David O'Meara
Steve Fahlbusch

Joined: Sep 18, 2000
Posts: 601

Of the ones I have used, I ususally generate some pseudounique
keys than bounce off of a file (database) of used keys and then
find a appropriatily close key. This is usually some form of
hashing. How it normally works:
hash the key
look up to see if hashed key is in use
if not, mark as hashed, save object id (or whatever)
if it is, look for next unused hash, mark as hashes save object id.
I agree. Here's the link:
subject: Unique Key Generation
It's not a secret anymore!