Caused by: org.h2.jdbc.JdbcSQLDataException: Hexadecimal string contains non-hex character

Caused by: org.h2.jdbc.JdbcSQLDataException: Hexadecimal string contains non-hex character

non hex character in a hex string
hexadecimal string with odd number of characters
hexadecimal string with odd number of characters localdatetime
h2 mode=postgresql
sql error: 90004, sqlstate: 90004
hexadecimal string with odd number of characters enum
h2 clob example
h2 uuid

I'm trying to write tests using in-memory DB. I wrote an sql to clean and store data to DB. But I have an exception:

Caused by: org.h2.jdbc.JdbcSQLDataException: Hexadecimal string contains non-hex character: "e7485042-b46b-11e9-986a-b74e614de0b0"; SQL statement:
insert into users (user_id, name, created_on, modified_on) values ('e7485042-b46b-11e9-986a-b74e614de0b0', 'Ann', null, null) -- ('e7485042-b46b-11e9-986a-b74e614de0b0', 'Ann', NULL, NULL) [90004-199]

My sql:

insert into users (user_id, name, created_on, modified_on) values ('e7485042-b46b-11e9-986a-b74e614de0b0', 'Ann', null, null);

insert into product(product_id, name, created_on, modified_on) VALUES ('f3a775de-b46b-11e9-95e4-af440b6044e6', 'product1', '2019-08-01 17:51:51.000000', '2019-08-01 17:51:51.000000');

insert into products_users(user_id, product_id) VALUES ('e7485042-b46b-11e9-986a-b74e614de0b0', 'f3a775de-b46b-11e9-95e4-af440b6044e6');

My application.properties:

spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=

spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

Using spring.datasource.url=jdbc:h2:mem:testdb;MODE=MYSQL fixed it for me.

Or adding an annotation @Type to the UUID field should fix the issue:

@Id
@Type(type="uuid-char")
private UUID user_id;

Error 90004: Hexadecimal string contains non-hex character � Issue , Caused by: org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non- hex character: "PUBLIC"; SQL statement: select publicatio0_. The data type for left is correctly determined to be String (because it is a VARCHAR in the database), but that for right gets determined as byte for the failing test cases. The same line returns String for both sides for the query that works.


The actual cause of this problem is the mapping between your object and the generated create table statement by hibernate (ddl-auto:create) used to create your h2 database schema.

If you enable the output of the those ddl statements using:

spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=true
spring.jpa.properties.hibernate.format_sql=true
logging.level.org.hibernate.type=TRACE

you will most likely see that your UUID class has been mapped to a binary column in your database.

Hibernate: 
    create table <your_table> (
        id bigint generated by default as identity,
        ...,
        <your_object> binary(255),
        ...
        primary key (id)
    )

This means that your uuid-string contains illegal characters. You need a varchar(<uuid-length>) column. There are several solution strategies, one of them is defining a type, see this StackOverflow answer. You can read on binary columns on the official MySQL reference site.

Hexadecimal string contains non-hex character: "jdoe"; SQL , Caused by: org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non- hex character: "jdoe"; SQL statement: SELECT count(*) FROM� Hexadecimal string contains non-hex character: "jdoe"; SQL statement: #934. burakuluu opened this issue Mar 6, Caused by: org.h2.jdbc.JdbcSQLException


I resolved this problem by adding spring.jpa.hibernate.ddl-auto=none to my application.properties file

Error 90004: Hexadecimal string contains non-hex character , Caused by: org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non- hex character: "PUBLIC"; SQL statement: select publicatio0_."id" as id1_0_� You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].


JdbcSQLException: Hexadecimal string contains non-hex character, Caused by: org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non- hex character: "d4b87ccd-0aa5-4b79-aa69-5d8648b32410";� Re: [h2] "Hexadecimal string contains non-hex character" when opening db Showing 1-4 of 4 messages


Re: [h2] "Hexadecimal string contains non-hex character" when , A user with H2 in an application gets this error code: "org.h2.jdbc. JdbcSQLException: Hexadecimal string contains non-hex character: "- psn_0_57358" [90004-176]". Could meta-data get corrupted and cause this? For future students that may run into this issue: The problem was with how the h2 database was taking in the dateUploaded information. To verify you have the same problem, check the H2 Console and see if under the GIF table, the DATEUPLOADED is of the datatype VARBINARY.


org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non , readthefuckingmanual.net � [SOLVED] org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non-hex character. Error added: 2017-09-12T19:01: 30Z� When converting a number to a number of another type, the value is checked for overflow. When converting a number to binary, the number of bytes matches the precision. When converting a string to binary, it is hex encoded (every byte two characters); a hex string can be converted to a number by first converting it to binary.