使用Eclipse进行Hibernate配置

本文详细介绍了如何在Eclipse环境下配置Hibernate,包括导入所需类包,创建hibernate.cfg.xml配置文件并解决数据库连接时区问题,以及创建实体类和映射文件。在配置数据库连接时,通过Data Source Explorer解决了缺少DB browser的问题,并针对jdbc时区错误给出了添加serverTimezone参数的解决方案。
摘要由CSDN通过智能技术生成

使用Eclipse进行Hibernate配置

*所有步骤按照老师视频的顺序进行,过程中遇到的问题已经基本解决。

1.新建Java文件,导入Hibernate文件所需要的类包、连接MySQL所使用的jdbc以及日志类"log4j-1.2.17.jar和slf4j-log4j12-1.7.7.jar。
在这里插入图片描述所需的所有类包如下:
在这里插入图片描述
2.在src目录下添加配置文件hibernate.cfg.xml。

<!--
  ~ Hibernate, Relational Persistence for Idiomatic Java
  ~
  ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
  ~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
  -->
<!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.dialect">MySQLInnoDBDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hellohibernate?serverTimezone=UTC</property>
<property name="hibernate.connection.username">root</property>
<property name="hi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值