刚开始学习J2EE,第一次使用Hibernate连接数据库,发现出现无法连接数据库的情况。在查阅了各种资料的情况下,尝试各种方式解决无果后,终于发现了问题真正所在——Mysql版本过高(Mysql8.0)与起始的hibernate.cfg.xml文件无法匹配。
首先放出原始的hibernate.cfg.xml代码:
<?xml version="1.0" encoding="UTF-8"?>
<!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.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/j2ee</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.dialect">org