How to fix “Error executing DDL ”alter table events drop foreign key FKg0mkvgsqn8584qoql6a2rxheq“ via JDBC Statement”

前端 未结 9 1543
刺人心
刺人心 2021-02-04 04:44

I\'m trying to start spring boot project with MySQL database, but I have some problem with database. I try to start my application that, and server is running but hibernate don\

相关标签:
9条回答
  • 2021-02-04 04:47

    Hmm I also encountered this issue but either of those solutions could not solve my issue. I am using MySQL database packaging with XAMPP. What I tried out to solve but failed

    • I deleted my Database located in "xampp\mysql\data"
    • I renamed my conflicted tables
    • Although I kept this "spring.jpa.hibernate.ddl-auto=update" setting in at start.

    So what I did to solve this issue. Might be yours

    • I completely uninstalled the XAMPP package and Installed it again.
    • I created new database name
    • RUN the application

    Friends it actually my circumstances, might be help your issue like me. If you have any question please post comment. Thanks

    0 讨论(0)
  • 2021-02-04 04:55

    Ran into similar issue and found SupaMario's answer here.

    In my case I had a table named orders but MySql threw the error as it seems to be a reserve table / keyword.

    I changed it to customer_order and it all worked fine.

    0 讨论(0)
  • 2021-02-04 04:56

    Change The dialect of hibernate.cfg.xml Dialect :- org.hibernate.dialect.MySQL5InnoDBDialect OR org.hibernate.dialect.MySQL55Dialect OR org.hibernate.dialect.MySQL55InnoDBDialect OR org.hibernate.dialect.MySQL57InnoDBDialect

    0 讨论(0)
  • 2021-02-04 04:56

    Ok, had the same issue. Adding prefixes fixed the problem for me:

    from:

    `
    @Entity
    @Table(name = "result_man")
    @Proxy(lazy = false)
    public class ResultManEntity {
    @Id
    @GeneratedValue
    @Column(name = "id", unique = true, length = 128)
    private long id;
    private String key;
    private int score;
    private int index;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "result_id")
    private ResultEntity result;
    }`
    

    to:

    `@Entity
    @Table(name = "result_man")
    @Proxy(lazy = false)
    public class ResultManEntity {
    @Id
    @GeneratedValue
    @Column(name = "id", unique = true, length = 128)
    private long id;
    private String _key;
    private int _score;
    private int _index;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "result_id")
    private ResultEntity result;`
    
    0 讨论(0)
  • 2021-02-04 04:57

    In my case the problem why i got this exception was, that some tables had names which are reserved for postgreSQL. eg. "Like" or "User". Changed name with:

    @Table(name="likes") 
    

    and it worked fine. Perhaps someone has the same problem.

    0 讨论(0)
  • 2021-02-04 04:58

    Change spring.jpa.hibernate.ddl-auto = create-drop to update. It is dropping the database at start so wont find the required events table to alter anything.

    0 讨论(0)
提交回复
热议问题