hibernate文件配置

<?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">
<hibernate-configuration>
<session-factory >
<!-- 连接数据库 -->
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">123456</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
<property name="hibernate.connection.username">test01</property>
<!-- 数据库方案 -->
<property name="hibernate.default_schema">TEST01</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<!-- 调试 -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<!-- 自动建表方式 -->
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- 注册映射文件 -->
<mapping resource="com/hanqi/entity/Region.hbm.xml"/>
<mapping resource="com/hanqi/entity/Bank.hbm.xml"/>
</session-factory>
</hibernate-configuration>

  Struts文件配置:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <constant name="Struts.action.extension" value="action,do,,"></constant> <package name="index" extends="struts-default"> <action name="testAction" class="com.hanqi.action.testAction" method="testWeb"> <result name="ok">test1.jsp</result>
</action>
<!-- 解耦接口方式 -->
<action name="testActionAware" class="com.hanqi.action.testActionAware" method="testAware">
<result name="ok">test1.jsp</result>
</action> <!-- 以ServletActionConttext方式访问文本资源 -->
<action name="testServletAction" class="com.hanqi.action.testServletAction" method="testServletAction">
<result name="ok" >test1.jsp</result>
</action> <!-- ServletAware接口方式 -->
<action name="testServletAction" class="com.hanqi.action.TestServletAware" method="testServlet">
<result name="ok" >test1.jsp</result>
</action> </package> </struts>

 hibernate配置Dao连接数据库

private Configuration cfg=null;

    private ServiceRegistry sr=null;

    private SessionFactory sf=null;

    private Session se=null;

    private Transaction ts=null;

    public BankDao()
{
//加载配置文件
cfg=new Configuration().configure();
//注册服务
sr=new StandardServiceRegistryBuilder()
.applySettings(cfg.getProperties()).build();
} private void init()
{
sf=cfg.buildSessionFactory(sr); se=sf.openSession(); ts=se.beginTransaction();
} private void destroy()
{
ts.commit(); se.close(); sf.close();
}

 

配置hibernate,Struts。文件的更多相关文章

  1. SSH整合,applicationContext.xml中配置hibernate映射文件问题

    今天在applicationContext.xml中配置sessionFactory时遇到了各种头疼的问题,现在总结一下: 1.<property name="mappingDirec ...

  2. spring配置hibernate映射文件-------通配符

    <!-- 这里一定要注意是使用spring的mappingLocations属性进行通配的 -->      <property name="mappingLocation ...

  3. 用Spring的mappingDirectoryLocations来配置Hibernate映射文件

    在Spring的applicationContext.xml中配置映射文件的方法: <property name="mappingResources">     < ...

  4. hibernate配置和映射文件

    映射文件 <?xml version="1.0" encoding="utf-8"?><!DOCTYPE hibernate-mapping ...

  5. Hibernate映射文件如何配置触发器

    Hibernate映射文件之触发器生成(generated属性.database-object元素) (2013-02-27 12:28:49) 转载▼ 标签: it 分类: JAVA学习笔记 这里分 ...

  6. Spring,hibernate,struts的面试笔试题(含答案)

    Hibernate工作原理及为什么要用? 原理: 1.读取并解析配置文件 2.读取并解析映射信息,创建SessionFactory 3.打开Sesssion 4.创建事务Transation 5.持久 ...

  7. Spring集成Hibernate映射文件的4种方式

    概要: 在Spring的applicationContext.xml中集成Hibernate映射文件,通常是在<sessionFactory>这个Bean实例中进行的,若配置的映射文件较少 ...

  8. spring加载hibernate映射文件的几种方式。转自:http://blog.csdn.net/huiwenjie168/article/details/7013618

    在Spring的applicationContext.xml中配置映射文件,通常是在<sessionFactory>这个Bean实例中进行的,若配置的映射文件较少时,可以用sessionF ...

  9. Struts文件上传allowedTypes问题,烦人的“允许上传的文件类型”

    Struts的文件上传问题,相信很多人都会使用allowedTypes参数来配置允许上传的文件类型,如下. <param name="allowedTypes"> im ...

随机推荐

  1. iPhone Anywehre虚拟定位提示“后台服务未启动,请重新安装应用后使用”的解决方法

    问题描述: iPhone越狱了,之后在Cydia中安装Anywhere虚拟定位,但是打开app提示:后台服务未启动,请重新安装应用后使用. 程序无法正常使用... 解决方法: 打开Cydia-已安装, ...

  2. 算法与数据结构(十三) 冒泡排序、插入排序、希尔排序、选择排序(Swift3.0版)

    本篇博客中的代码实现依然采用Swift3.0来实现.在前几篇博客连续的介绍了关于查找的相关内容, 大约包括线性数据结构的顺序查找.折半查找.插值查找.Fibonacci查找,还包括数结构的二叉排序树以 ...

  3. Response.Redirect引起的性能问题分析

    现象: 最近做的一个系统通过单点登录(SSO) 技术验证用户登录.用户在SSO 系统上通过验证后,跳转到该系统的不同模块.而跳转的时间一直维持子啊几分钟左右. 分析步骤: 在问题复现时抓取Hang d ...

  4. javascript运动系列第一篇——匀速运动

    × 目录 [1]简单运动 [2]定时器管理 [3]分享到效果[4]移入移出[5]运动函数[6]透明度[7]多值[8]多物体[9]回调[10]函数完善[11]最终函数 前面的话 除了拖拽以外,运动也是j ...

  5. Node.js npm 详解

    一.npm简介 安装npm请阅读我之前的文章Hello Node中npm安装那一部分,不过只介绍了linux平台,如果是其它平台,有前辈写了更加详细的介绍. npm的全称:Node Package M ...

  6. EF上下文对象线程内唯一性与优化

    在一次请求中,即一个线程内,若是用到EF数据上下文对象,就创建一个,这也加是很多人的代码中习惯在使用上下文对象时,习惯将对象建立在using中,也是为了尽早释放上下文对象, 但是如果有一个业务逻辑调用 ...

  7. [WPF] Wait for a moment.

    一.控件介绍 在 WPF 中使用的等待控件,控件包括三种,普通的等待信息提示(WaitTip),进度条提示(WaitProgress),以及主程序覆盖的模拟时钟等待窗口(WaitClock),具体效果 ...

  8. MySQL Workbench建表时 PK NN UQ BIN UN ZF AI 的含义

    [转自网络]https://my.oschina.net/cers/blog/292191 PK Belongs to primary key 作为主键 NN Not Null 非空 UQ Uniqu ...

  9. WebAPI

    WebAPI的Host OWIN IIS WebAPI 的handler和Filter有啥区别? WebAPI  常用 Filters Exception Filter Timer Filter Lo ...

  10. No plugin found for prefix ‘jetty’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories

    maven配置文件(最大的那个)的<pluginGroups></pluginGroups>增加一行如下<pluginGroups><pluginGroup& ...