对于hibernate 5.X hibernate.cfg.xml 需要这么写 注意MySQL5Dialect中有个5

来源:1-11 通过Hibernate API编写访问数据库的代码

慕粉3287174

2018-06-26 19:17

<hibernate-configuration>

<session-factory>


<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate?serverTimezone=UTC&amp;characterEncoding=utf8&amp;useUnicode=true&amp;useSSL=false</property>

<property name="connection.username">root</property>

<property name="connection.password">yanxin</property>

<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>

<property name="show_sql">true</property>

<property name="format_sql">true</property>

<property name="hbm2ddl.auto">create</property>

<mapping resource="Students.hbm.xml"/>

</session-factory>

</hibernate-configuration>


写回答 关注

1回答

  • 慕粉3287174
    2018-06-26 19:20:13

    坑好多

Hibernate初探之单表映射

Java持久化框架Hibernate入门教程,掌握Hibernate基本概念

74801 学习 · 835 问题

查看课程

相似问题