Jump to content

Let's talk about MySQL Connection Pooling


Archon

Recommended Posts

Firstly, this is probably not the correct section but hopefully the ones who visit this section have better knowledge on the subject.

I understand that pooling connections allows for connections to be 'recycled' but whenever I read about the action of pooling connections there is always something that states: "Make sure you close the connection when you're finished with it to put it back into the pool."

Now, I've also read that having to re-open a connection is very costly, so I don't see how a pool helps if the connection is always being closed and re-opened.

Someone help me better understand this subject,

Archon

Link to comment
Share on other sites

I've never used connection pooling with any of my programs and never had any problems with MySQL. I used to run an RSPS that was fairly big, maxed 750 players and I used MySQL for nearly everything. As long as you reuse prepared statements and use batched statements where possible you should be fine on terms of performance. If you're worried about performance issues caused by connecting to a database then do all database I/O away from the main thread, you could use Callable<T> or RunnableFuture<T> to return ResultSets, both found in the java.util.concurrency package. 

Edited by Haridos
Link to comment
Share on other sites

ALWAYS close a connection after you're done with that statement. If your program is big, and you got like 100+ SQL-statements and they're all Connection.Open() at the same time, the performance will get fucked.

 

Do you have any clue what you're talking about? Opening and closing a MySQL connection for each statement is a bad idea, as this will cause a massive bottleneck in your application. Reusing connections is fine and is what the SQL library in java was designed for.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...