学习Hibernate——配置Hibernate环境
2017-03-28 22:59
281 查看
一、概念。
hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,使得Java程序员可以随心所欲的使用对象编程思维来操纵数据库。既然学习Hibernate那么第一步就要学会如何配置hibernate环境。只有配置好环境才能进行hibernate项目的编写。下面我就为大家介绍如何配置Hibernate。
二、配置Hibernate步骤。
2.1添加jar包。
把hibernate-3.2.0.ga\hibernate-3.2\lib下的所有jar包加上。
2.2编写hibernate.cfg.xml
[html] view
plain copy
<!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_frist</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>
<property name="hibernate.format_sql">true</property>
<mapping resource="com/bjpowernode/hibernate/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,使得Java程序员可以随心所欲的使用对象编程思维来操纵数据库。既然学习Hibernate那么第一步就要学会如何配置hibernate环境。只有配置好环境才能进行hibernate项目的编写。下面我就为大家介绍如何配置Hibernate。
二、配置Hibernate步骤。
2.1添加jar包。
把hibernate-3.2.0.ga\hibernate-3.2\lib下的所有jar包加上。
2.2编写hibernate.cfg.xml
[html] view
plain copy
<!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_frist</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>
<property name="hibernate.format_sql">true</property>
<mapping resource="com/bjpowernode/hibernate/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
相关文章推荐
- 菜鸟学习Hibernate——配置Hibernate环境
- ssh学习:hibernate环境配置及开发步聚
- 菜鸟学习Hibernate——配置Hibernate环境
- Hibernate学习笔记之开发环境的配置
- Hibernate学习第一天 配置环境和helloworld
- hibernate学习(环境配置)
- 传智播客hibernate学习,开发环境配置
- hibernate学习日志一:环境配置
- Java学习之hibernate配置要点详谈
- EJB3.0学习之运行环境配置
- Hibernate学习手记——SQL server MiddleGen配置问题
- J2EE学习笔记二:配置一个简单的J2EE测试环境
- Struts+Spring+Hibernate开发环境架构配置
- EJB3.0学习之运行环境配置
- java环境的配置学习
- 今天开始学习WCF了----开发环境的配置
- Ajax 学习手扎(一)Ajax 的环境配置
- DirectShow学习之一在vs2005中配置directshow开发环境
- MyEclipse+Struts+Hibernate环境配置与开发
- 配置Hibernate环境