`

Dealing with MySQL connection death after 8 hours

 
阅读更多

Hardly anything is more frustrating than coming back the day after to find your beautifully configured Pentaho installation handing up obscure error messages and seeming to hobble about as you log in and try to execute reports.

 

MySQL connections timeout by default every 8 hours.  If Pentaho sits idle for more than 8 hours, its connection to the repository silently drops dead without Pentaho's knowledge.  When something stirs Pentaho after an 8 hour or greater time lapse, Pentaho assumes that its connection is still alive and currently there is no default mechanism in place that handles bringing a connection back to life.  Enter c3p0 (JDBC Connection Pooling software).

 

The solution turns out to be fairly easy.  What is required is a piece of software to manage the database connection pool and keep the connections alive.  The recommended method is to use c3p0.

 

More information about c3p0 can be found on the project's site:

 

http://sourceforge.net/projects/c3p0
http://www.mchange.com/projects/c3p0/index.html

To use c3p0 to solve this problem, first download the c3p0-0.9.1.2.bin.zip, stop your Java application server, take the jar files c3p0-0.9.2.jar and mchange-commons-java-0.2.3.3.jar inside the downloaded archive and copy them to your WEB-INF/lib directory on your java application server. I use Tomcat 6 on Ubuntu 8.10, so my installation path happens to be:

/var/lib/tomcat6/webapps/pentaho/WEB-INF/lib

Next, we'll need to modify the hibernate settings for MySQL.  The file we will modify is called mysql5.hibernate.cfg.xml and is located in the pentaho-solutions/system/hibernate folder by default.

 

You will insert the following text just after the <session-factory> tag and just before the <!-- MySQL Configuration --> comment.

        <!--
            hibernate c3p0 settings
        -->

        <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <property name="hibernate.c3p0.acquire_increment">3</property>
        <property name="hibernate.c3p0.idle_test_period">10</property>
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.max_size">75</property>
        <property name="hibernate.c3p0.max_statements">0</property>
        <property name="hibernate.c3p0.timeout">25200</property>
        <property name="hibernate.c3p0.preferredTestQuery">select 1</property>
        <property name="hibernate.c3p0.testConnectionOnCheckout">true</property>


        <!--
            hibernate cache settings
        -->
	<!-- End of patch added Friday April 3, 2009 to address issues of the database connection going dead
	-->

        <property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
        <property name="hibernate.generate_statistics">true</property>
        <property name="hibernate.cache.use_query_cache">true</property>

 

That's all there is to it.  Save the file and restart your application server and the dead connection problem should go away.

分享到:
评论

相关推荐

    八年级英语Dealing with troublePPT课件.pptx

    这篇PPT课件是针对八年级英语教学的内容,主题为“应对困难”(Dealing with trouble)。通过一系列的填空练习和情景模拟,旨在帮助学生掌握如何在不同情况下正确处理问题,尤其是面对紧急情况时的应对策略。以下是...

    Dealing with Undesirable Outputs in DEA: A Slacks-based Measure(SBM) Approach

    在进行数据包络分析(Data Envelopment Analysis, DEA)研究时,经常需要面对的问题之一是如何处理非期望产出(undesirable outputs)。传统DEA模型在处理生产效率分析时通常假设决策单元(Decision Making Units, ...

    Image Processing:Dealing With Texture

    《图像处理:处理纹理》是图像处理领域内一部权威性的著作,由Maria Petrou和Pedro Garcia Sevilla两位学者共同编写,他们分别来自英国伦敦帝国理工学院和西班牙卡斯特利翁的Jaume I大学。该书由全球知名的学术出版...

    r scripts for dealing with mturk survey

    R scripts for dealing with mturk

    Dealing with stress.doc

    "Dealing With Stress" 这个主题的工作坊就是为此而设,旨在帮助参与者理解和管理他们面临的压力。 首先,我们要理解压力的来源。在大学生活中,学生面临的主要压力源包括: 1. **学术压力**:大学课程繁重,报告...

    dealing with hard people

    "Dealing with Hard People"这一主题,虽然看似不直接涉及技术,但它实际上对提升工作效率和团队协作至关重要。在这个知识领域,我们将深入探讨如何在复杂的职场环境中处理人际关系,特别是那些难缠的人物。 首先,...

    Chapter 3 Dealing with trouble测试题2.doc

    Chapter 3 Dealing with trouble测试题2.doc

    Dealing_With_Difficult_People (en)

    - - 与人交往中注意的一些容易被跳过的细节.以及基础理论分析与人交往出现的情况.

    MySQL V5.5帮助文档

    2.9.5. Dealing with Problems Compiling MySQL 2.9.6. MySQL Configuration and Third-Party Tools 2.10. Postinstallation Setup and Testing 2.10.1. Unix Postinstallation Procedures 2.10.2. Securing the ...

    Dealing with Audio Ground Loops

    音频地环回问题详解 音频地环回是音频系统中常见的问题,主要由于不同设备通过不同的路径连接到共同的地线而产生。这种多路径接地方式实际上就像一个天线,会拾取并引入干扰。当地环回发生时,地线(通常是屏蔽层)...

    八年级英语Dealing with troublePPT学习教案.pptx

    这篇PPT学习教案是针对八年级英语的一课,主题为"Dealing with trouble",旨在帮助学生学习如何处理各种突发状况。以下是对其中涉及的知识点的详细解释: 1. **词汇与短语**: - **hurry**:匆忙,表示动作迅速。 ...

    处理不均衡数据 (深度学习)! Dealing with imbalanced data (deep learning)

    处理不均衡数据_(深度学习)!_Dealing_with_imbalanced_data_(deep_learning)

    MySQL++ 3.2.1

    It is built around the same principles as the Standard C++ Library, to make dealing with the database as easy as dealing with STL containers. In addition, MySQL++ provides facilities that let you ...

    ASTM E178 - 21 Standard Practice for Dealing With Outlying Obser

    标题中的"ASTM E178 - 21"指的是美国材料与...通过阅读提供的"ASTM E178 - 21 Standard Practice for Dealing With Outlying Observations - 完整英文版(11页).pdf"文件,可以深入学习这一标准的细节和具体实施步骤。

    MFC dealing with window size_IntheFrame_MFC实例_

    在Microsoft Foundation Class (MFC)库中,"MFC dealing with window size_IntheFrame_MFC实例_" 主题涉及如何在框架窗口(Frame Window)中管理子窗口(Subwindow)的大小。MFC是C++的一个类库,它为Windows应用...

    MySql存储过程编程.chm

    Dealing with Errors Section 2.8. Interacting with the Database Section 2.9. Calling Stored Programs from Stored Programs Section 2.10. Putting It All Together Section 2.11. Stored Functions ...

    mysql C++ API

    MySQL++ relieves the programmer of dealing with cumbersome C data tructures, generation of repetitive SQL statements, and manual creation of C++ data structures to mirror the database schema.

    MySQL C++ Wrapper

    It is built around the same principles as the Standard C++ Library, to make dealing with the database as easy as dealing with STL containers. In addition, MySQL++ provides facilities that let you ...

    Data Wrangling with JavaScript

    Chapter 7 Dealing With Huge Data Files Chapter 8 Working With A Mountain Of Data Chapter 9 Practical Data Analysis Chapter 10 Browser-Based Visualization Chapter 11 Server-Side Visualization Chapter ...

    mysqlfront2.5

    MySQL-Front is an easy-to-use-interface for web-workers dealing with MySQL-Databases. It requires libmySQL.dll from the MySQL-Server as "API" (included in this package - newest version available at ...

Global site tag (gtag.js) - Google Analytics