Hibernate auto create database

后端 未结 4 1581
花落未央
花落未央 2020-12-02 20:19

I have a Java EE Hibernate project, and I\'m using MySQL as a database.

I want that when I first time run the project, it will create the database automatically.

4条回答
  •  感动是毒
    2020-12-02 20:56

    create will create tables. But it will not create database. Change the connection url to generate the database.

    com.mysql.jdbc.Driver
    jdbc:mysql://localhost/InternetProject?createDatabaseIfNotExist=true
    root
    
    10
    

    Update : character encoding when creating database

    
        jdbc:mysql://localhost/InternetProject?createDatabaseIfNotExist=true&useUnicode=yes&characterEncoding=UTF-8
    
    

提交回复
热议问题