Running out of DB connections!

前端 未结 5 1688
误落风尘
误落风尘 2021-02-03 11:52

I\'m running a Spring/Hibernate connecting to MySQL setup using c3p0 as my connection pool. For some bizarre reason it runs out of connections when the system is under load (of

5条回答
  •  后悔当初
    2021-02-03 12:41

    Regardless of the configuration you have for C3P0 (through hibernate) you might have a restriction imposed by MySQL itself. Keep in mind that by default the maximum number of connections allowed by MySQL is 100! So even if you tell C3P0 to pool up to 200, 500 or 1000 connections, this will be unachievable. Open a MySQL shell using:

    $ msql -u [user] -p
    

    And type the following to get the maximum number of connections allowed:

    $ show variables where Variable_name='max_connections';
    

    If the number returned is too low for your application, consider changing it (edit your my.cnf file, usually located inside /etc/mysql/ on Linux systems).

提交回复
热议问题