I'm using UUID for my id column, I'm looking for a way to retrieve the data inside my Java application. I can't find a method in ResultSet for getting a UUID. How would I go about getting the UUID?
PostgreSQL allows you store and compare UUID values but it does not include functions for generating the UUID values in its core. Instead, it relies on the third-party modules that provide specific algorithms to generate UUIDs.
Postgres natively supports UUID as a data type, even capable of being indexed and used as primary key. But to generate a UUID value, such as to establish a default value for a column, you need a Postgres extension (a plugin).
What is the Postgres UUID Type? The Postgres UUID data type stores UUIDs as defined by RFC 4122, which are 128-bit quantities generated by algorithms that minimize the probability of having duplicate identifiers. A UUID comprises of 32 hexadecimal digits, represented in groups of 8,4,4,4 and 12.
The data type uuid stores Universally Unique Identifiers (UUID) as defined by RFC 4122, ISO/IEC 9834-8:2005, and related standards. (Some systems refer to this data type as a globally unique identifier, or GUID, instead.)
Here is how it's done for anyone who searches
(java.util.UUID) result.getObject("id")
or
result.getObject("id", java.util.UUID.class)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With