SS3.1_Hibernate_ByMyEclipse 使用MyEclipse创建Hibernate项目
2017-02-05 23:54
344 查看
在hibernate.cfg.xml文件中配置MySQL数据库连接参数:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/testdb</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<property name="current_session_context_class">thread</property>
</session-factory>
</hibernate-configuration>
从项目SS1.1_Hibernate_ByManual中把net.nw.dao和net.nw.vo两个包复制粘贴到本项目SS3.1_Hibernate_ByMyEclipse当中直接使用
在hibernate.cfg.xml文件中注册映射文件,如红色粗体字行标识的那样:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/testdb</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<property name="current_session_context_class">thread</property>
<mapping resource="net/nw/vo/Student.hbm.xml" />
</session-factory>
</hibernate-configuration>
测试效果截图如下:
相关文章推荐
- S2.1_Struts2_ByMyEclipse使用MyEclipse创建Struts2项目
- JPA项目使用myeclipse创建带注解的model实体类&web工程使用MyEclipse自动生成hibernate映射文件和实体类
- 使用Maven管理项目-----创建Struts2,Spring,Hibernate项目
- 使用 MyEclipse 插件创建 Hibernate + Struts 连接oracle实例(动画)
- Intellij IDEA使用注解创建Hibernate项目中的OR映射类
- 使用Dockerfile构建MyEclipse创建的JavaWeb项目 - 知识林
- 用MyEclipse创建一个Struts+Hibernate项目
- maven项目创建图解(推荐使用eclipse MARS.2),不推荐使用Myeclipse
- 框架 day38 SVN安装及使用,SSH练习项目CRM,环境搭建(myeclipse hibernate 反转引擎生成PO和映射)
- 使用Myeclipse创建第一个Maven项目
- MyEclipse使用Maven创建web项目+搭建SSM框架教程
- 使用Myeclipse创建ExtJS项目HelloWorld程序
- 使用myeclipse自带的maven创建新项目,直接执行maven install报错
- 使用Myeclipse创建Maven项目--步骤详解及遇到的问题
- 使用Maven管理项目-----创建 Struts2,Spring,Hibernate项目
- 使用 MyEclipse 插件创建 Hibernate + Struts 实例(动画)
- 在MyEclipse的web项目/java项目中,使用Hibernate-tools中的hbm2java和hbm2ddl工具,根据hbm文件自动生成pojo和数据库脚本
- mac 使用MyEclipse时遇到无法创建web项目问题解决方法
- Myeclipse2014使用maven创建web项目
- 使用MyEclipse创建Maven项目出现的错误及解决方法