• Hibernate 配置C3P0 连接池


    第一步在hibernate.cfg.xml配置

    <!-- 连接池 -->
            <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
            <!-- 最大连接数 -->
            <property name="hibernate.c3p0.max_size">20</property>
            <!-- 最小连接数 -->
            <property name="hibernate.c3p0.min_size">5</property>
            <!-- 获得连接的超时时间,如果超过这个时间,会抛出异常,单位毫秒 -->
            <property name="hibernate.c3p0.timeout">120</property>
            <!-- 最大的PreparedStatement的数量 -->
            <property name="hibernate.c3p0.max_statements">100</property>
            <!-- 每隔120秒检查连接池里的空闲连接 ,单位是秒 -->
            <property name="hibernate.c3p0.idle_test_period">120</property>
            <!-- 当连接池里面的连接用完的时候,C3P0一下获取的新的连接数 -->
            <property name="hibernate.c3p0.acquire_increment">2</property>
            <!-- 每次都验证连接是否可用 -->
            <property name="hibernate.c3p0.validate">false</property>

    然后!!!!!!!遇到的异常======

    配置不使用单纯的JDBC连接,也是在hibernate.cfg.xml配置

        <property name="hibernate.temp.use_jdbc_metadata_defaults">false</property> 

    第三部导包,D:hibernate-release-4.2.21.Finalliboptionalc3p0下面的包都导过来

  • 相关阅读:
    hdoj_1711Number Sequence
    心痛
    2012国信蓝桥初赛试题
    poj_2524Ubiquitous Religions
    poj_2406Power Strings && poj_1961Period && poj_2752Seek the Name, Seek the Fame(KMP)
    POJ并查集小结
    并查集模版
    hdoj_1232畅通工程 && hdoj_1272小希的迷宫 && hdoj_1213How Many Tables && Is It A Tree?
    poj_1611The Suspects
    KMP模版
  • 原文地址:https://www.cnblogs.com/Damon-Luo/p/5637931.html
Copyright © 2020-2023  润新知