Unable to create requested service [org.hibernate .engine.jdbc.env.spi.JdbcEnvironment]-MySQL

前端 未结 6 1642
眼角桃花
眼角桃花 2021-02-15 17:54

I am a newbie to Hibernate. I am currently using Spring boot framework and trying to create database tables through hibernate.

I know the same question is asked before b

相关标签:
6条回答
  • 2021-02-15 18:32

    Upgrade MySql driver to mysql-connector-java - 8.0.17 and

    Those who are using greater than MySQL 5.5 version

    change their driver property

    from com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver

    because:

    Loading class com.mysql.jdbc.Driver. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.INFO - HHH000401: using driver [com.mysql.jdbc.Driver] at URL....

    in hibernate.properties

    hibernate.connection.driver_class = com.mysql.cj.jdbc.Driver
    

    or if you are using hibernate.cfg.xml update

    <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
    
    0 讨论(0)
  • 2021-02-15 18:34

    Use HSQLDialect not MYSQLDialect

    spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect
    spring.jpa.hibernate.ddl-auto=none
    spring.jpa.show-sql=true
    
    
    spring.datasource.url=jdbc:mysql://localhost:3306/xyz?serverTimezone=CST6CDT
    spring.datasource.username=root
    spring.datasource.password=root
    spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
    
    0 讨论(0)
  • 2021-02-15 18:42

    connection.driver_class property must be compatible with mysql-connector jar.

    mysql-connector < 5.5.xx use com.mysql.jdbc.Driver

    mysql-connector > 5.5.xx use com.mysql.cj.jdbc.Driver

    0 讨论(0)
  • 2021-02-15 18:42

    I had the same issue when I deployed my war file to tomcat in my demo environment. My application was not getting started because, in my /tomcat/webapp/ROOT folder, I found my war file Myapp.war there. i.e. In my ROOT folder, it has WEB-INF, META-INF, and Myapp.war, which caused the startup issue. I deleted the war file and it worked.

    0 讨论(0)
  • 2021-02-15 18:49
     <property name="connection.url">jdbc:mysql://localhost:3306/test?serverTimezone=UTC</property>
    

    You need to set serverTimezone.

    0 讨论(0)
  • 2021-02-15 18:50

    You need to add mysql JDBC jar in your dependencies.


    1. Fix your driver class name as com.mysql.jdbc.Driver.
    2. Fix your username and password property as

      "connection.username" for database user
      "connection.password" for database user password
      
    3. Create mysql database. See this.

    4. For SSL warning, modify your connection.url to include use ssl false. For example, jdbc:mysql://localhost:3306/<enter-your-database>?autoReconnect=true&useSSL=false

    5. Modify your mysql dialect to org.hibernate.dialect.MySQLDialect

    6. Use <property name="hbmdl.auto">create-drop</property> instead of <property name="hbmdl.auto">update</property> however do not use this option in production. You should create schema yourself and not do it via hibernate.
    0 讨论(0)
提交回复
热议问题