尝试运行Hibernate(Java)程序时无法连接到数据库(MySQL

enxuqcxy  于 2023-01-15  发布在  Java
关注(0)|答案(1)|浏览(161)
<?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 ="dialect">org.hibernate.dialect.MySQLDialect</property>
 <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name ="conection.url">jdbc:mysql://localhost:3306/employeesdb</property>
<property name ="connection.username">root</property>
<property name ="connection.password">password@123</property>

<property name ="hbm2ddl.auto">update</property>
<property name ="show_sql">true</property>
 <property name="current_session_context_class">thread</property>

<mapping class = "com.start.Student"></mapping>

</session-factory>
</hibernate-configuration>

通常我应该能够连接到数据库,但我得到了一个错误。错误:- “线程“main”java.lang中出现异常。应用程序必须提供JDBC连接”
这意味着我无法连接DB。我已检查数据库用户名和密码是否正确。ERRORMain Program

shstlldc

shstlldc1#

您在conection.url中有打字错误。应为connection.url

相关问题