Reputation: 363
I have a spring boot application working fine on a H2 DB. If I want to switch to postgresQL I get errors.
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
Errors:
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "drop table if exists
user cascade" via JDBC Statement
...
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "user"
...
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table user (id int8 not null, active int4 not null, first_name varchar(255), last_name varchar(255), password varchar(255), role varchar(255), username varchar(255), primary key (id))" via JDBC Statement
Upvotes: 4
Views: 4751
Reputation: 462
I think this is because user
is a reserved word in PostrgeSQL.
In order to create a table with such name, try quote it (that is, create table "user"
...)
Enclosing all the objects' names in 'ANSI quotes' is generally a good idea if you want an interoperability between different databases.
Upvotes: 13