Hey,
I want to test my database pooling so I figured to start queries on a separate thread. This works and I see the active and idle connections increase. But I had just a couple of these threads in line. For some real testing (completely drain the pool and see what happens) I figured to put the thread creation in a loop but this results in having at most 1 active connection and after thread 1 they all finish in 0ms. I have not done much with threads but it's probably not a good idea to create those in a loop.
for (int i = 0; i < 100; i++)
{
final int y = i;
Thread t = new Thread()
{
@Override
public void run() {
long start = System.nanoTime();
DataSourceExample db = new DataSourceExample();
System.out.println("Thead " + (y + 1) + " finished in: " + ((System.nanoTime() - start) / 1000000) + "ms.");
}
};
t.run();
}
But how can I (stres) test my MySQL database properly? I am using java `import org.apache.commons.dbcp2.BasicDataSource;` to create the pool. I have no experience with testing these.