我有一些使用MAMP从MySQL数据库导出的blob十六进制值。我试图将这些值添加到H2数据库,但我不断收到错误:
org.h2.jdbc.JdbcSQLException: Hexadecimal string with odd number of characters: "80273753912952185238922745508880797601482513992540829416944108482201678079823009423240796439787688076562876906583780517704249256776629049440054030707230103901187860416530898080584543691951511619479802824069658267005899514817053628822676904964354186008390099680162497341280836375590099576180828248580706583256766125057680523862652582731318422096302127828322568212884418137380647350895148022669223845592468192584084729728626393575544"; SQL statement:
INSERT INTO `StatisticsExplanationActivity` VALUES(2, '2012-06-01 11:36:36', '0', '2012-06-01 11:36:37', 1, 16, 0x00aced0005737200136a6176612e7574696c2e41727261794c6973747881d21d99c7619d03000149000473697a6578700000000577040000000a7400196d757365756d507265666572656e63655f6f7269656e74616c7400166d757365756d507265666572656e63655f70686f746f740014696465616c686f6c79646179735f75726261696e7400176e696768744576656e696e67486f6262795f6d757369637400106d75736963616c54617374655f706f7078) -- (2, '2012-06-01 11:36:36', '0', '2012-06-01 11:36:37', 1, 16, 80273753912952185238922745508880797601482513992540829416944108482201678079823009423240796439787688076562876906583780517704249256776629049440054030707230103901187860416530898080584543691951511619479802824069658267005899514817053628822676904964354186008390099680162497341280836375590099576180828248580706583256766125057680523862652582731318422096302127828322568212884418137380647350895148022669223845592468192584084729728626393575544) [90003-166]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.util.StringUtils.convertHexToBytes(StringUtils.java:990)
相同的INSERT行适用于MySQL。我在其他一些主题上看到,当H2的多线程模式启用时,可能会发生这种情况。我想尝试一下,但我不知道如何使用Play设置该参数! 1.2.x的。
编辑:尝试了MULTI_THREADED但仍然遇到同样的错误。 EDIT2:忘记发布我使用的十六进制数字:
0xaced0005737200136a6176612e7574696c2e41727261794c6973747881d21d99c7619d03000149000473697a6578700000000577040000000a7400196d757365756d507265666572656e63655f6f7269656e74616c7400166d757365756d507265666572656e63655f70686f746f740014696465616c686f6c79646179735f75726261696e7400176e696768744576656e696e67486f6262795f6d757369637400106d75736963616c54617374655f706f7078
答案 0 :(得分:2)
H2数据库将0x00aced0...
解释为数字(Java BigDecimal),然后尝试将toString()表示(十进制数)转换为十六进制编码二进制。
这当然不是你想要的,大约50%的情况都失败了。
因此,您需要使用0x00aced0...
(引用)
'00aced0...'