org.springframework.jdbc.datasource.init.ScriptStatementFailedException

tip

Check if you're not creating unused SQL entities, as it might cause this exception.


rafael

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • Layers not saved in the workspace
    via GitHub by gpetit
    ,
  • H2 and Oracle Compatiability issues
    via Stack Overflow by john
    ,
    • org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement at line 1 of resource class path resource [test-data.sql]: insert into contact (first_name, last_name, birth_date) values ('Chris', 'Schaefer', '1981-05-03') at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.executeSqlScript(ResourceDatabasePopulator.java:202) at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:135) at org.springframework.jdbc.datasource.init.CompositeDatabasePopulator.populate(CompositeDatabasePopulator.java:56) at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:47) Caused by: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "UQ_CONTACT_1_INDEX_6 ON PUBLIC.CONTACT(FIRST_NAME, LAST_NAME) VALUES ('Chris', 'Schaefer', 1)"; SQL statement: insert into contact (first_name, last_name, birth_date) values ('Chris', 'Schaefer', '1981-05-03') [23505-192] at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) at org.h2.message.DbException.get(DbException.java:179) at org.h2.message.DbException.get(DbException.java:155) at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:103) at org.h2.mvstore.db.MVSecondaryIndex.checkUnique(MVSecondaryIndex.java:231) at org.h2.mvstore.db.MVSecondaryIndex.add(MVSecondaryIndex.java:190) at org.h2.mvstore.db.MVTable.addRow(MVTable.java:704) at org.h2.command.dml.Insert.insertRows(Insert.java:156) at org.h2.command.dml.Insert.update(Insert.java:114) at org.h2.command.CommandContainer.update(CommandContainer.java:98) at org.h2.command.Command.executeUpdate(Command.java:258) at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:184) at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:158) at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.executeSqlScript(ResourceDatabasePopulator.java:187) ... 4 more

    Users with the same issue

    tvrmsmith
    4 times, last one,
    Unknown visitor1 times, last one,
    archenroot
    1 times, last one,
    Andreas Häber
    5 times, last one,
    Unknown visitor2 times, last one,
    143 more bugmates