sql2o

How to save a UUID as binary(16) in java

无人久伴 提交于 2019-12-05 02:29:31
问题 I have a table TestTable with columns ID as binary(16) and name as varchar(50) I've been trying to store an ordered UUID as PK like in this article Store UUID in an optimized way I see the UUID is saved in database as HEX (blob) So I want to save this ID from java but I am getting this error Data truncation: Data too long for column 'ID' at row 1 I am currently using the library sql2o to interact with mysql So basically this is my code String suuid = UUID.randomUUID().toString(); String

How to save a UUID as binary(16) in java

江枫思渺然 提交于 2019-12-03 17:13:26
I have a table TestTable with columns ID as binary(16) and name as varchar(50) I've been trying to store an ordered UUID as PK like in this article Store UUID in an optimized way I see the UUID is saved in database as HEX (blob) So I want to save this ID from java but I am getting this error Data truncation: Data too long for column 'ID' at row 1 I am currently using the library sql2o to interact with mysql So basically this is my code String suuid = UUID.randomUUID().toString(); String partial_id = suuid.substring(14,18) + suuid.substring(9, 13) + suuid.substring(0, 8) + suuid.substring(19,