亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3680 | 回復(fù): 1
打印 上一主題 下一主題

各種數(shù)據(jù)源配置之Spring+JPA配置BoneCP數(shù)據(jù)源 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2012-03-19 17:40 |只看該作者 |倒序?yàn)g覽
各種數(shù)據(jù)源配置之Spring+JPA配置BoneCP數(shù)據(jù)源










xml代碼:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.        xmlns:context="http://www.springframework.org/schema/context"
  5.        xmlns:aop="http://www.springframework.org/schema/aop"
  6.        xmlns:tx="http://www.springframework.org/schema/tx"
  7.        xsi:schemaLocation="http://www.springframework.org/schema/beans
  8.            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  9.            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
  10.            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
  11.            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
  12.     <aop:aspectj-autoproxy/>
  13.    
  14.     <context:component-scan base-package="com.huhui"/><!-- 掃描注解方式 -->
  15.    
  16.     <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
  17.     <property name="persistenceUnitName" value="huhui"/>
  18.     </bean>
  19.    
  20.     <!-- 配置事務(wù)管理器 -->
  21.     <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
  22.         <property name="entityManagerFactory" ref="entityManagerFactory"/>
  23.     </bean>
  24.    
  25.    <tx:annotation-driven transaction-manager="transactionManager"/>
  26. </beans>
復(fù)制代碼
web.xml代碼:
  1. <context-param>
  2.     <param-name>contextConfigLocation</param-name>
  3.     <param-value>classpath:beans.xml</param-value>
  4. </context-param>
復(fù)制代碼
其它的略

persistence.xml代碼:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instanc"
  3. xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
  4. <persistence-unit name="huhui" transaction-type="RESOURCE_LOCAL">
  5. <provider>org.hibernate.ejb.HibernatePersistence</provider>
  6. <properties>
  7. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>

  8. <property name="hibernate.connection.driver_class" value="org.gjt.mm.mysql.Driver"/>
  9. <property name="hibernate.connection.username" value="root"/>
  10. <property name="hibernate.connection.password" value="root"/>
  11. <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/huhui?useUnicode=true&amp;characterEncoding=UTF-8"/>
  12. <property name="hibernate.max_fetch_depth" value="3"/>
  13. <property name="hibernate.hbm2ddl.auto" value="update"/>
  14. <property name="hibernate.jdbc.fetch_size" value="18"/>
  15. <property name="hibernate.jdbc.batch_size" value="10"/>
  16. <property name="hibernate.show_sql" value="false"/>
  17. <property name="hibernate.format_sql" value="false"/>

  18. <property name="hibernate.connection.provider_class" value="com.jolbox.bonecp.provider.BoneCPConnectionProvider"/>
  19. <property name="hibernate.connection.provider_class" value="com.jolbox.bonecp.provider.BoneCPConnectionProvider"/>
  20. <!-- 設(shè)置連接的空閑存活時(shí)間,默認(rèn)為60,單位:分鐘 -->
  21. <property name="bonecp.idleMaxAge" value="240"/>
  22. <!-- 設(shè)置測試connection的間隔時(shí)間。這個(gè)參數(shù)默認(rèn)為240,單位:分鐘 -->
  23. <property name="bonecp.idleConnectionTestPeriod" value="60"/>
  24. <!-- 設(shè)置分區(qū)個(gè)數(shù)。這個(gè)參數(shù)默認(rèn)為1,建議3-4(根據(jù)特定應(yīng)用程序而定) -->
  25. <property name="bonecp.partitionCount" value="3"/>
  26. <!-- 設(shè)置分區(qū)中的連接增長數(shù)量。這個(gè)參數(shù)默認(rèn)為1 -->
  27. <property name="bonecp.acquireIncrement" value="10"/>
  28. <!-- 設(shè)置每個(gè)分區(qū)含有連接最大個(gè)數(shù)。這個(gè)參數(shù)默認(rèn)為2 -->
  29. <property name="bonecp.maxConnectionsPerPartition" value="300"/>
  30. <!-- 設(shè)置每個(gè)分區(qū)含有連接最大小個(gè)數(shù)。這個(gè)參數(shù)默認(rèn)為0 -->
  31. <property name="bonecp.minConnectionsPerPartition" value="20"/>
  32. <!-- 設(shè)置statement緩存?zhèn)數(shù)。這個(gè)參數(shù)默認(rèn)為0 -->
  33. <property name="bonecp.statementsCacheSize" value="50"/>
  34. <!-- 設(shè)置連接助手線程個(gè)數(shù)。這個(gè)參數(shù)默認(rèn)為3 -->
  35. <property name="bonecp.releaseHelperThreads" value="3"/> </properties>
  36. </persistence-unit>
  37. </persistence>
復(fù)制代碼
配置數(shù)據(jù)源時(shí),我個(gè)人不喜歡配置多個(gè)數(shù)據(jù)源。以上使用的數(shù)據(jù)源是BoneCP數(shù)據(jù)源,性能比C3P0好,當(dāng)然也不是說不用C3P0了。下次我會(huì)給出C3P0的配置代碼及其Jar包

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2012-03-19 20:20 |只看該作者
謝謝分享
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP