In the following scenario:
1 Database 4 Web Servers
How do web servers generate a unique identifier for the database to be unique? Yes, it is possible to use Auto-increment, but it is too easy to scan / guess / etc. Thus, auto-increment is currently not an option.
Use the UUID ( http://www.ietf.org/rfc/rfc4122.txt ). Collisions are unlikely and can be considered when they occur by regenerating a new UUID, or they can be prevented by combining a unique identifier for each server (for example, MAC address): -
StringBuilder sb = new StringBuilder(UUID.randomUUID()); InetAddress address = InetAddress.getLocalHost(); String uid = sb.append(NetworkInterface.getByInetAddress(address).getHardwareAddress());
You can use UUID:
import java.util.UUID; UUID uuid = UUID.randomUUID(); System.out.println(uuid.toString());
, . , / .
? , ? ?
, , , .
, . , ""? , , , - ?
, , UUID, .
, , . , : , 12345678, 0 12345678-1 .
, . , , , , , . , .
, , , , -. , - " ", , - , . , 3 . , , , . id , , IP- - .
Source: https://habr.com/ru/post/1721498/More articles:open source - translationВоспроизведение mp3 в WPF - c#Stop uninstalling on MySQL via triggers - sqlPostgreSQL analogue of SQL Server index (including columns) - sqlSaving PDO information in php.ini - databaseUnit test product with license file - nunitSwampy.1.1 with Python 3 - pythonHow do you cancel your href = "javascript: void (null)"? - javascript.NET: DataAnnotation Attributes in General - c #Is there a way to add event handlers for controls in C # without using a constructor? - c #All Articles