当processlist在raspberry pi中超过100个连接时,mysql数据库挂起

时间:2015-02-06 08:35:02

标签: java mysql hibernate raspberry-pi

我正在使用c3p0概念在hibernate中编写服务。这个服务部署到Raspberry pi。 raspbery pi 有512 MB的RAM。当进程列表超过100个连接时,我不断地使用该服务挂起的mysql。我的服务无法正常工作。重新启动mysql后,只有所有进程列表都将它们自行杀死。然后服务正常工作,直到进程列表达到100个以上的连接。

我的c3p0配置是( hibernate.cfg 文件),

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>
    <!-- Database connection settings -->
         <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">mani</property>
        <property name="hibernate.connection.password">admin</property>
     <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>        
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="show_sql">true</property>
        <property name="hbm2ddl.auto">update</property>
        <property name="current_session_context_class">thread</property>
        <!-- <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> -->
        <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <property name="hibernate.c3p0.min_size">10</property>
        <property name="hibernate.c3p0.max_size">100</property>
        <property name="hibernate.c3p0.max_statements">50</property>
        <property name="hibernate.c3p0.maxIdleTime">1800</property>
        <property name="hibernate.c3p0.maxIdleTimeExcessConnections">300</property>
        <property name="hibernate.c3p0.acquire_increment">1</property>
        <property name="hibernate.c3p0.idle_test_period">30</property>
        <property name="hibernate.c3p0.validate">true</property>
        <property name="hibernate.c3p0.preferredTestQuery">SELECT 1</property>
        <property name="hibernate.c3p0.testConnectionOnCheckin">true</property> 
        <property name="hibernate.c3p0.testConnectionOnCheckout">false</property>                      
        <!-- Mention here all the pojo classes along with their package name -->
        <mapping class="com.nutans.objects.Dialog" />
        <mapping class="com.nutans.objects.Office" />
        <mapping class="com.nutans.objects.Welcome" />
        <mapping class="com.nutans.objects.Sports"/>

    </session-factory>

</hibernate-configuration>

帮帮我吧!

0 个答案:

没有答案