Arya
Arya

Reputation: 8985

Reading UUID from result set in Postgres JDBC

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?

Upvotes: 16

Views: 11148

Answers (1)

Arya
Arya

Reputation: 8985

Here is how it's done for anyone who searches

(java.util.UUID) result.getObject("id")

or

result.getObject("id", java.util.UUID.class)

Upvotes: 36

Related Questions