MySQL connection (Java Clients) setup to avoid User XXXX already has more than 'max_user_connections' active connections
NOTE: This is sample for our Private JVM clients, but can be used also for our shared JVM clients as well.
When setting your MySQL connection pool, is important to implement max user connection limit, in order to avoid keeping idle MySQL connections, which MySQL considers as persistent non-idle connection, and which leads to your database user exceeding our safe MySQL limits. The following example can be safely used on any of our Private JVM servers, as well as VPS/Cloud servers using our Private JVM plugin.
<Resource name="jdbc/SampleDB" auth="Container"
username="mysql_user" password="mysql_pass" initialSize="1" maxActive="5" maxIdle="5"
maxWait="15000" removeAbandoned="true" removeAbandonedTimeout="300" logAbandoned="true"
validationQuery="select now();" />
NOTE: We use Remote MySQL servers for our Private JVM shared packages, check this article for details on what your hostname might be. You can use for hostname "localhost" on our VPS/Cloud servers.