<?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
              xmlns:xsi
          ="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation
          ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
          <!--===================================================================-->
              
          <!--建立c3p0 dataSource-->
          <!--===================================================================-->
              
          <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
          <!--===================================================================-->
              
          <!--指明數(shù)據(jù)庫驅(qū)動(以MySql為例)-->
          <!--===================================================================-->
                  
          <property name="driverClass">
                      
          <value>com.mysql.jdbc.Driver</value>
                  
          </property>
          <!--===================================================================-->
              
          <!--指明數(shù)據(jù)庫地址以及編碼-->
          <!--===================================================================-->
                  
          <property name="jdbcUrl">
                   
          <value>jdbc:mysql://localhost:3306/yxs?useUnicode=true&amp;characterEncoding=UTF-8&amp;autoReconnect=true</value>
                  
          </property>
          <!--===================================================================-->
              
          <!--指明數(shù)據(jù)庫的用戶名和密碼-->
          <!--===================================================================-->
                  
          <property name="properties">
                      
          <props>
                          
          <prop key="user">root</prop> 
                          
          <prop key="password">1234</prop>
          <!--===================================================================-->
              
          <!--配置c3p0參數(shù)-->
          <!--===================================================================-->
                          
          <prop key="hibernate.c3p0.acquire_increment">2</prop>
                          
          <prop key="hibernate.c3p0.idle_test_period">3000</prop>
                          
          <prop key="hibernate.c3p0.timeout">5000</prop>
                          
          <prop key="hibernate.c3p0.max_size">800</prop>
                          
          <prop key="hibernate.c3p0.min_size">1</prop>
                          
          <prop key="hibernate.c3p0.max_statements">800</prop>
                          
          <prop key="hibernate.c3p0.validate">false</prop>
                          
          <prop key="c3p0.testConnectionOnCheckout">true</prop>
                      
          </props>
                  
          </property>
              
          </bean>
          <!--===================================================================-->
              
          <!--把數(shù)據(jù)源注入給Session工廠-->
          <!--===================================================================-->
              
          <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                  
          <property name="dataSource" ref="dataSource" />
          <!--===================================================================-->
              
          <!--配置映射文件-->
          <!--===================================================================-->
                  
          <property name="mappingResources">
                      
          <list>
                          
          <value>/com/linying/domain/User.hbm.xml</value>
                          
                      
          </list>
                  
          </property>
          <!--===================================================================-->
              
          <!--配置Hibernate-->
          <!--===================================================================-->
                  
          <property name="hibernateProperties">
                      
          <value>
                          hibernate.dialect=com.linying.beans.MySQLDialect
                          hibernate.show_sql=true
                          hibernate.generate_statistics=true
                          hibernate.transaction.flush_before_completion=true
                          hibernate.transaction.auto_close_session=true
                          hibernate.autoReconnect=true
                      
          </value>
                  
          </property>
              
          </bean>
              
          <bean id="jdbcExceptionTranslator"
                  class
          ="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
                  
          <property name="dataSource">
                      
          <ref bean="dataSource" />
                  
          </property>
              
          </bean>
              
          <bean id="hibernateTemplate"
                  class
          ="org.springframework.orm.hibernate3.HibernateTemplate">
                  
          <property name="sessionFactory">
                      
          <ref bean="sessionFactory" />
                  
          </property>
                  
          <property name="jdbcExceptionTranslator">
                      
          <ref bean="jdbcExceptionTranslator" />
                  
          </property>
              
          </bean>
              
          <bean id="transactionManager"
                  class
          ="org.springframework.orm.hibernate3.HibernateTransactionManager">
                  
          <property name="sessionFactory" ref="sessionFactory" />
                  
          <property name="jdbcExceptionTranslator">
                      
          <ref bean="jdbcExceptionTranslator" />
                  
          </property>
              
          </bean>
              
          <bean id="transactionTemplate"
                  class
          ="org.springframework.transaction.support.TransactionTemplate">
                  
          <property name="transactionManager" ref="transactionManager" />
              
          </bean>
          <!--DAO================================================================-->
              
          <bean id="commonDao" class="com.linying.dao.CommonDaoImpl">
                  
          <property name="hibernateTemplate" ref="hibernateTemplate"/>
                  
          <property name="transactionTemplate" ref="transactionTemplate"/>
              
          </bean>
          <!--beans================================================================-->
              
          <bean id="login" class="com.linying.service.login.Login">
                  
          <property name="commonDao" ref="commonDao"/>
              
          </bean>
          </beans>
          posted on 2010-03-25 20:15 Ying-er 閱讀(615) 評論(0)  編輯  收藏 所屬分類: SSH
          主站蜘蛛池模板: 淄博市| 珠海市| 武穴市| 潜山县| 内乡县| 灌阳县| 清远市| 岳池县| 固始县| 福安市| 新平| 鹤山市| 利津县| 环江| 嘉鱼县| 岳普湖县| 积石山| 百色市| 盐山县| 罗山县| 吉木萨尔县| 招远市| 年辖:市辖区| 平武县| 库车县| 马边| 昔阳县| 十堰市| 大冶市| 万源市| 玉门市| 固原市| 北川| 宾川县| 崇左市| 博兴县| 江阴市| 大宁县| 泾川县| 五莲县| 樟树市|