I'm using hibernate with DB2 database. When I'm running spring batch job I have following exception:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement; SQL [insert into "PERSON" (id, first_name, last_name) values (default, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: could not prepare statement
When I paste query from log to IBM Data Studio I see that query is seems to lack quotes on field names. The valid statement would be
insert into "PERSON" ("id", "first_name", "last_name") values (default, 'John122', 'Doe21')
How can I fix this?
Thanks
There's a difference between the following two statements:
create table Person ( id integer, first_name vargraphic(80), last_name vargraphic(80) );
and
create table "Person" ( "id" integer, "first_name" vargraphic(80), "last_name" vargraphic(80) );
The first statement creates the table PERSON, with column ID, FIRST_NAME and LAST_NAME (mind the uppercase!). The second statement creates the table Person with the columns id, first_name and last_name.
It seems that you created your table with the second definition, but are trying to update it with a statement correct for the first table definition.
TL;DR: DB2 always creates all table and column names in uppercase, unless the names are between (double) quotes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.