Passing UUID() to MySQL

Note that many databases cannot return UUIDs that are auto-generated by your database (but see the exception here). But the whole point of UUIDs is that they can be generated at any point with extreme confidence of no collisions. That means if you need the UUID later in your code, you should generate it with java as Nick shows, and hang onto it.

(If your DB supports UUID columns, don't stringify it.)

3 Likes