Talha Tanveer
Talha Tanveer

Reputation: 1256

How to limit the number of MYSQL Database connections?

I am developing an application in Java which will be distributed across many people. However I don't want a thousand clients connected at the same time therefore I want to limit the number of connections on my Apache MYSQL Server. I am using xampp for this and I wanna know how do I limit/change the number of connections at one time.

Upvotes: 0

Views: 289

Answers (2)

g00dnatur3
g00dnatur3

Reputation: 1193

If you are using Java, I'd recommend c3p0

http://www.mchange.com/projects/c3p0/

or Apache Commons DBCP

http://commons.apache.org/proper/commons-dbcp/

http://wiki.apache.org/commons/DBCP

Cheers!

Upvotes: 1

Alexandre Santos
Alexandre Santos

Reputation: 8338

Your question is really broad, so my answer has to be broad as well.

You should study more how connections and clients work.

Just because you have thousands of clients, it doesn't mean you will need thousands of connections. This is because every client doesn't take up one connection.

What happens is, at some level, a pool of connections is created and this pool of connections is shared amongst all client calls.

The last "p" in your xampp means PHP (or Perl), so they would be the ones responsible for controlling the connection pool. So, my advice is look for connection pools in PHP or Perl.

As an example on how to use connection pool with Java, follow this tutorial: http://www.javaworld.com/article/2076221/jndi/dive-into-connection-pooling-with-j2ee.html

Upvotes: 1

Related Questions