Hibernate configuration error problem occurs summary

<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
    	<!-- 一、 数据库连接的参数配置 -->
    	<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/app?useUnicode=true&amp;characterEncoding=utf8</property>
    	<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    	<property name="hibernate.connection.username">root</property>
    	<property name="hibernate.connection.password">root</property>
    	<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    
    	<!-- 二、 hibernate其他常用配置 -->
    	<property name="hibernate.show_sql">true</property><!--
    	<property name="hibernate.format_sql">true</property>
    	--><property name="hibernate.hbm2ddl.auto">update</property>
    	
    	<!-- 三、加载映射文件
    	<mapping resource="cn/itcast/a_status/Employee.hbm.xml"/>-->
    	<mapping resource="entity/User.hbm.xml"/> 
    	
    </session-factory>
</hibernate-configuration>

1, url to add utf-8, plus there will be no

Unknown initial character set index '255' received from server. Initial client character 

Solve: https://blog.csdn.net/txwtech/article/details/80787886

2, & can not write directly, should read: & amp; or will be error (in xml when configuring the database utl configuration file, use the escape character & is & amp;)

Database Connectivity given : entity "characterEncoding" reference must start with ';' end with a delimiter

3. plus time zone

jdbc:mysql://localhost:3306/houses?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC

4. The new version of the driver is

com.mysql.cj.jdbc.Driver

serverTimezone = Asia / Shanghai (solve jet lag)

Guess you like

Origin blog.csdn.net/weixin_42533856/article/details/84404312