Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • Thank you for your answer that explains well the problematic domain. I can clearly understand the advantages of using this techinque, however I've never used connection pools and I'm little bit worried that this would mean a lot of changes in our current code (we've implemented almost all of requirements). It's not that complex software (it's school project), however we are limited with time. I try to wrap my head around how much code we would need to change. Does it mean that if we used database queries like the one from example, it would mean drastical changes? Commented May 17, 2019 at 21:11
  • The use of connection pools is part of most jdbc drivers. As far as I know, they are active by default so it is quite likely that you already use them without knowing it Commented May 17, 2019 at 21:15
  • Ohh, seems that I might be a little wrong and got confused with .Net drivers where it is a simple part of the connection string (e.g. setting Pooling=true; for mysql. In java it seems that you need extra software as c3p0 (mchange.com/projects/c3p0/index.html) or Apache Commons DBCP (commons.apache.org/proper/commons-dbcp) Commented May 17, 2019 at 21:22
  • 1
    Partly true, but using DriverManager like the OP is doing is considered the 'old-fashioned' way of establishing connections. The 'modern' way is using an implementation of javax.sql.DataSource, so switching between non-pooling and pooling would normally be a matter of switching out the DataSource implementation (which in most frameworks is a matter of configuration, and not necessarily code). Commented May 18, 2019 at 7:29