hibernate C3P0資料來源 串連oracle資料庫

來源:互聯網
上載者:User

<?xml version="1.0" encoding="UTF-8"?><br /><beans xmlns="http://www.springframework.org/schema/beans"<br /> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br /> xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> </p><p> <!-- 定義資料來源Bean,使用C3P0資料來源實現 --><br /> <bean id="dataSource"<br /> class="com.mchange.v2.c3p0.ComboPooledDataSource"<br /> destroy-method="close"><br /> <!-- 指定串連資料庫的驅動 --><br /> <property name="driverClass"<br /> value="oracle.jdbc.driver.OracleDriver" /><br /> <!-- 指定串連資料庫的URL --><br /> <property name="jdbcUrl"<br /> value="jdbc:oracle:thin:@192.168.1.102:1521:orcl" /><br /> <!-- 指定串連資料庫的使用者名稱 --><br /> <property name="user" value="sys as sysdba" /><br /> <!-- 指定串連資料庫的密碼 --><br /> <property name="password" value="wxp362387" /><br /> <!-- 指定串連資料庫連接池的最大串連數 --><br /> <property name="maxPoolSize" value="40" /><br /> <!-- 指定串連資料庫連接池的最小串連數 --><br /> <property name="minPoolSize" value="10" /><br /> <!-- 指定串連資料庫連接池的初始化串連數 --><br /> <property name="initialPoolSize" value="10" /><br /> <!-- 指定串連資料庫連接池的串連的最大空閑時間 --><br /> <property name="maxIdleTime" value="20" /><br /> </bean><br /> <!--定義了Hibernate的SessionFactory --><br /> <bean id="sessionFactory"<br /> class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><br /> <property name="dataSource" ref="dataSource" /><br /> <!-- 配置Hibernate的參數 --><br /> <property name="hibernateProperties"><br /> <props><br /> <!-- 指定資料庫的方言 --><br /> <prop key="hibernate.dialect"><br /> org.hibernate.dialect.Oracle9Dialect<br /> </prop><br /> <prop key="show_sql">true</prop><br /> <prop key="hibernate.hbm2ddl.auto">update</prop><br /> <!-- JDBC執行批次更新語句的大小 --><br /> <prop key="hibernate.jdbc.batch_size">20</prop><br /> </props><br /> </property><br /> <property name="mappingResources"><br /> <!-- 映射的檔案 --><br /> <list><br /> <value>XXXX.hbm.xml</value> </p><p> </list><br /> </property><br /> </bean><br /> <!-- 配置交易管理員Bean,因為使用Hibernate持久化技術,故使用HibernateTranscationManager 交易管理員 --><br /> <bean id="transactionManager"<br /> class="org.springframework.orm.hibernate3.HibernateTransactionManager"><br /> <!--為交易管理員注入SessionFactory 引用 --><br /> <property name="sessionFactory" ref="sessionFactory" /><br /> </bean><br /> <!-- 配置事務攔截器Bean --><br /> <bean id="transactionInterceptor"<br /> class="org.springframework.transaction.interceptor.TransactionInterceptor"><br /> <!-- 事務攔截器bean需要依賴注入一個交易管理員 --><br /> <property name="transactionManager" ref="transactionManager" /><br /> <property name="transactionAttributes"><br /> <!-- 下面定義事務傳播屬性--><br /> <props><br /> <prop key="save*">PROPAGATION_REQUIRED</prop><br /> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop><br /> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop><br /> <prop key="*">PROPAGATION_REQUIRED</prop><br /> </props><br /> </property><br /> </bean> </p><p> <!-- 定義BeanNameAutoProxyCreator 後處理器 ,BeanNameAutoProxyCreator為名字匹配字串或者萬用字元的bean自動建立AOP代理。--><br /> <bean<br /> class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"><br /> <!-- 指定對滿足哪些bean name的bean自動產生業務代理 --><br /> <property name="beanNames"><br /> <!-- 下面是所有需要自動建立事務代理的bean--><br /> <list><br /> <value>*Dao</value><br /> <value>*Imp</value> </p><p> </list><br /> <!-- 此處可增加其他需要自動建立事務代理的bean--><br /> </property><br /> <!-- 下面定義BeanNameAutoProxyCreator所需的事務攔截器--><br /> <property name="interceptorNames"><br /> <list><br /> <!-- 此處可增加其他新的Interceptor --><br /> <value>transactionInterceptor</value><br /> </list><br /> </property><br /> </bean> </p><p> <!-- 配置系統DAO組件 --><br /> <bean id="xxxxDao" class="org.boss.dao.XxxxDaoHibernate"><br /> <!-- 依賴注入DAO組件所必需的SessionFactory引用 --><br /> <property name="sessionFactory" ref="sessionFactory"></property><br /> </bean><br /> <!-- 配置系統的商務邏輯組件 --><br /> <bean id="xxxxImp" class="org.boss.service. XxxxManagerImp"><br /> <property name="xxxxDao" ref="xxxxDao"></property><br /> </bean><br /></beans> </p><p>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.