Archon Posted October 30, 2013 Share Posted October 30, 2013 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 More sharing options...
Haridos Posted November 1, 2013 Share Posted November 1, 2013 (edited) 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 November 1, 2013 by Haridos Link to comment Share on other sites More sharing options...
Someluser Posted November 1, 2013 Share Posted November 1, 2013 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. Link to comment Share on other sites More sharing options...
Haridos Posted November 3, 2013 Share Posted November 3, 2013 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 More sharing options...
Gloves Posted November 3, 2013 Share Posted November 3, 2013 your pest control script sucks 1 Link to comment Share on other sites More sharing options...