本篇博客将带着大家以一个简单的实例来学习hibernate项目。
1、创建java项目
2、创建User Library,加入依赖包* HIBERNATE_HOME/lib/*.jar
* HIBERNATE_HOME/hibernate3.jar
* 加入数据库驱动(mysql驱动)
具体的操作步骤参考我的上一篇博客:【hibernate进阶】如何在myeclipse中添加jar包
3、提供hibernate.cfg.xml文件,完成基本的配置
<strong><span style="font-size:18px;"><!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.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate_first</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123</property>
<!-- mysql language adatper,if you want to change database ,you juse need to change there -->
<!--