问答详情
源自:1-11 通过Hibernate API编写访问数据库的代码

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

<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>


提问者:慕粉3287174 2018-06-26 19:17

个回答

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

    坑好多