1

我有一些使用 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
4

1 回答 1

2

H2 数据库将 解释0x00aced0...为数字(Java BigDecimal),然后尝试将 toString() 表示(十进制数字)转换为十六进制编码的二进制文件。

这当然不是您想要的,并且在大约 50% 的情况下它会失败。

因此,0x00aced0...您需要使用'00aced0...'(引用)而不是

于 2012-07-24T15:00:50.473 回答