What is the best way to generate a universally unique object ID? Do I need to use an external resource like a file or database, or can I do it all in memory?
Location: http://www.jguru.com/faq/view.jsp?EID=1030397 Created: Nov 25, 2002 Modified: 2003-02-28 08:01:34.258 Author: Alessandro A. Garbagnati (http://www.jguru.com/guru/viewbio.jsp?EID=32727) Question originally posed by Andy Brown (http://www.jguru.com/guru/viewbio.jsp?EID=1027054 [I need to generate unique id’s that will be used for node ‘ID’ attribute values within XML documents. This id must be unique system-wide. The generator must be available to a number of servlets that add various node structures to my XML docs as a service. What is the best way to tackle this? The ‘possible’ ways I can see: • Keep the maximum ID value in a flat-file where the service would read it upon start-up and increment it. Upon shutdown or failure, it would write the latest max id to the file. • Calculate the max id by searching the XML itself. This will be tougher since XML requires an alpha-numeric value (not strictly numeric). • Use a database (MySQL) with a two-field table where one field is the
Related Questions
- What is the best way to generate a universally unique object ID? Do I need to use an external resource like a file or database, or can I do it all in memory?
- When experimenting with creating negative afterimages, what type of external object is best to be practiced with?
- What is the best way to implement a system-wide object ID generator?