大三开的J2EE的课,第一节就遇到个大坑,我用的是之前安装的mysql8.0,死活运行不了
一度怀疑是代码或是eclipse出了问题
在工作室电脑上试了一下,代码没问题,原来是自己电脑数据库版本高的事
贴出原来的hibernate.cfg.xml配置
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernate_first</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>
<property name="hibernate.show_sql">true</property>
<mapping resource="*/User.hbm.xml"/><--!*s是路径-->
</session-factory>
</hibernate-configuration>
报错提示
搞了一下午可算成功了
贴出修改后的hibernate.cfg.xml
<session-factory>
<!--数据库名称:hibernate_first -->
<property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate_first?useSSL=false&serverTimezone=UTC</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<!-- 设置方言 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<mapping resource="test/User.hbm.xml"/>
</session-factory>
其中驱动,url和方言都需要修改