<?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">
          <!--===================================================================-->
              
          <!--指明數據庫驅動(以MySql為例)-->
          <!--===================================================================-->
                  
          <property name="driverClass">
                      
          <value>com.mysql.jdbc.Driver</value>
                  
          </property>
          <!--===================================================================-->
              
          <!--指明數據庫地址以及編碼-->
          <!--===================================================================-->
                  
          <property name="jdbcUrl">
                   
          <value>jdbc:mysql://localhost:3306/yxs?useUnicode=true&amp;characterEncoding=UTF-8&amp;autoReconnect=true</value>
                  
          </property>
          <!--===================================================================-->
              
          <!--指明數據庫的用戶名和密碼-->
          <!--===================================================================-->
                  
          <property name="properties">
                      
          <props>
                          
          <prop key="user">root</prop> 
                          
          <prop key="password">1234</prop>
          <!--===================================================================-->
              
          <!--配置c3p0參數-->
          <!--===================================================================-->
                          
          <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>
          <!--===================================================================-->
              
          <!--把數據源注入給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 閱讀(620) 評論(0)  編輯  收藏 所屬分類: SSH
          主站蜘蛛池模板: 金坛市| 宾川县| 荔浦县| 延边| 遂昌县| 巴彦县| 内黄县| 怀仁县| 伊春市| 尖扎县| 板桥市| 白城市| 富阳市| 宁德市| 德钦县| 平利县| 甘孜县| 班戈县| 金华市| 股票| 恩平市| 兴文县| 甘孜县| 淳安县| 鲜城| 临清市| 呼图壁县| 巍山| 东平县| 达日县| 古丈县| 汉沽区| 嵊州市| 万山特区| 盘锦市| 武城县| 龙山县| 自治县| 翁牛特旗| 南漳县| 金堂县|