Data conversion error converting error on H2

Asked 2 years ago, Updated 2 years ago, 78 views

I would like to add data from + in the image, but Blank is not allowed in H2 on the spring. "Data conversion error converting" error appears.

This error appears when the type is set to Integer.

environment

·spring(STS)

Reference

H2:

H2

STS:

STS

java spring spring-boot

2022-09-30 13:59

1 Answers

This is because the type of value you are trying to insert is different from the type in the column.

The SQL displayed in the attached image is missing, so I don't know exactly what it is, but the question statement suggests that you are trying to insert the string ' from in the column of type integer.

In this case, null should be configured.

Example Execution:

create table my_table(my_column integer);
insert into my_table(my_column) values(');
insert into my_table(my_column) values(null);

Results:

create table my_table(my_column integer);
Number of updates: 0
(1ms)

insert into my_table(my_column) values(');
Error occurred during data conversion "(MY_TABLE:"MY_COLUMN""INTEGER)"
Data conversion error converting ''(MY_TABLE: ''MY_COLUMN''"INTEGER); SQL statement:
insert into my_table(my_column) values(') [22018-200] 22018/22018 (Help)

insert into my_table(my_column) values(null);
Number of updates: 1
(0ms)


2022-09-30 13:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.