<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    解決tomcat經常掛掉的問題

     

    某天在服務器上的網頁打不開了,頻繁報以下錯誤。

    2007-3-18 1:08:26 org.apache.tomcat.util.threads.ThreadPool logFull
    嚴重: All threads (150) are currently busy, waiting. Increase maxThreads (150) or check the servlet status

    在網上找了些回答,以下是我覺得正確的回答:
    1.我想你的部分資源沒有釋放,積壓卡死的
    2.連接池問題
    3.應該是服務器端響應request的線程的處理時間過長導致的

    分析:
    當時使用網站的人數只有2個人,不可能答到到了并發線程150的上線。所以應該不是數據庫的問題。
    通過對出錯的提示判斷,應該是連接池使用不合理造成的,或者根本沒設置連接池。和數據庫連接的部分是使用Spring的數據源JDBC連的,如下:
    <beans>
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <!-- driver for MySQL-->
            <property name="driverClassName"><value>org.gjt.mm.mysql.Driver</value></property>
            <property name="url"><value>jdbc:mysql:// www.bt285.cn :3306/test?useUnicode=true&amp;characterEncoding=UTF8</value></property>
            <property name="username"><value>test</value></property>
            <property name="password"><value>test</value></property>      
    </beans>

    問題應該出現在Spring的DriverManagerDataSource上,它負責管理這些連接的。
    下邊是對DriverManagerDataSource 的解釋
    DriverManagerDataSource in Spring Framework

       javax.sql Interface DataSource

    Implementation of SmartDataSource that configures a plain old JDBC Driver via
    bean properties, and returns a new Connection every time.

    Useful for test or standalone environments outside of a J2EE container, either
    as a DataSource bean in a respective ApplicationContext, or in conjunction with
    a simple JNDI environment. Pool-assuming Connection.close() calls will simply
    close the connection, so any DataSource-aware persistence code should work.

    In a J2EE container, it is recommended to use a JNDI DataSource provided by the
    container. Such a DataSource can be exported as a DataSource bean in an
    ApplicationContext via JndiObjectFactoryBean, for seamless switching to and from
    a local DataSource bean like this class.

    If you need a "real" connection pool outside of a J2EE container, consider
    Apache's Jakarta Commons DBCP. Its BasicDataSource is a full connection pool
    bean, supporting the same basic properties as this class plus specific settings.
    It can be used as a replacement for an instance of this class just by changing
    the class name of the bean definition to
    "org.apache.commons.dbcp.BasicDataSource".

    -----------------------------------------------
    Many Jakarta projects support interaction with a relational database. Creating a
    new connection for each user can be time consuming (often requiring multiple
    seconds of clock time), in order to perform a database transaction that might
    take milliseconds. Opening a connection per user can be unfeasible in a
    publicly-hosted Internet application where the number of simultaneous users can
    be very large. Accordingly, developers often wish to share a "pool" of open
    connections between all of the application's current users. The number of users
    actually performing a request at any given time is usually a very small
    percentage of the total number of active users, and during request processing is
    the only time that a database connection is required. The application itself
    logs into the DBMS, and handles any user account issues internally.

    There are several Database Connection Pools already available, both within
    Jakarta products and elsewhere. This Commons package provides an opportunity to
    coordinate the efforts required to create and maintain an efficient,
    feature-rich package under the ASF license.

    The commons-dbcp package relies on code in the commons-pool package to provide
    the underlying object pool mechanisms that it utilizes.

    Applications can use the commons-dbcp component directly or through the existing
    interface of their container / supporting framework. For example the Tomcat
    servlet container presents a DBCP DataSource as a JNDI Datasource. James (Java
    Apache Mail Enterprise Server) has integrated DBCP into the Avalon framework. A
    Avalon-style datasource is created by wrapping the DBCP implementation. The
    pooling logic of DBCP and the configuration found in Avalon's excalibur code is
    what was needed to create an integrated reliable DataSource.

    看完了解釋,事實上是因為DriverManagerDataSource建立連接是只要有連接就新建一個connection,根本沒有連接池的作用。改為以下開源的連接池會好點。
    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName">
    <value>org.hsqldb.jdbcDriver</value>
    </property>
    <property name="url">
    <value>jdbc:hsqldb:hsql:// www.5a520.cn :9001</value>
    </property>
    <property name="username">
    <value>sa</value>
    </property>
    <property name="password">
    <value></value>
    </property>
    </bean>

    測試通過,問題消除,如果沒有搜索引擎找答案不會這么快解決問題。

    posted on 2009-03-19 13:03 wang9354 閱讀(3425) 評論(0)  編輯  收藏

    導航

    <2009年3月>
    22232425262728
    1234567
    891011121314
    15161718192021
    22232425262728
    2930311234

    統計

    常用鏈接

    留言簿(2)

    隨筆檔案

    友情鏈接

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 精品多毛少妇人妻AV免费久久| 亚洲xxxx18| a毛片全部免费播放| 国产亚洲一区二区三区在线不卡| 日本一区二区三区免费高清在线| 亚洲欧美日韩中文无线码| 成年男女免费视频网站| 亚洲色大成网站www永久网站| 青苹果乐园免费高清在线| 久久久久国产亚洲AV麻豆| 一级毛片**免费看试看20分钟| 亚洲黄片手机免费观看| 巨胸喷奶水www永久免费| 亚洲国产一成人久久精品| 久久亚洲精品成人无码| 免费国内精品久久久久影院| 亚洲喷奶水中文字幕电影| 免费无码AV片在线观看软件| 亚洲国产精品无码久久九九大片| 四虎永久成人免费影院域名| 成人a毛片视频免费看| 亚洲成AV人片在线观看WWW| 永久在线免费观看| 亚洲日本VA中文字幕久久道具| 免费jlzzjlzz在线播放视频| 和老外3p爽粗大免费视频| 亚洲av永久无码精品古装片| 久久国产一片免费观看| 久久国产精品亚洲综合| 歪歪漫画在线观看官网免费阅读| 亚洲成a∧人片在线观看无码 | 亚洲av成人一区二区三区在线播放| 亚洲国产精品成人久久蜜臀| 免费人成黄页在线观看日本| 亚洲综合一区国产精品| 亚洲午夜无码AV毛片久久| 99视频在线免费看| 亚洲sm另类一区二区三区| 亚洲精品中文字幕乱码三区| 成人免费无码视频在线网站| 国产午夜精品理论片免费观看|