Hibernate属性保持连接活动 [英] Hibernate Property To Keep Connections Alive

查看:155
本文介绍了Hibernate属性保持连接活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有任何Hibernate属性配置,以保持与MySql总是一定数量的连接?

There is any Hibernate property o configuration to keep alive always certain number of connection with MySql?

提前感谢。

推荐答案

我想你问连接池。您可以配置使用c3p0
像这样

I think you asking about connection pool. You can configure it e.g. using c3p0 Like this

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password"></property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/tutorials</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="show_sql">true</property>
        <property name="hibernate.
connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <property name="hibernate.c3p0.min_size">7</property>
        <property name="hibernate.c3p0.max_size">53</property>
        <property name="hibernate.c3p0.timeout">100</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.idle_test_period">1000</property>
        <property name="hibernate.c3p0.validate">true</property>
        <property name="hibernate.connection.provider_class">org.hibernate.service.
jdbc.connections.internal.C3P0ConnectionProvider</property>
        <mapping resource="com/javacodegeeks/Student.hbm.xml"></mapping>
    </session-factory>
</hibernate-configuration>

阅读更多此处

这篇关于Hibernate属性保持连接活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆