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
  • You should open a connection when you need data, get the data, and then close the connection. You can use a connection pool to make managing the connections a bit easier. Commented Mar 3, 2014 at 0:28
  • 1
    @GilbertLeBlanc Can a connection pool run out of connections to give? Commented Mar 3, 2014 at 0:42
  • Yes, it can run out of connections. It is unlikely, but possible. Commented Mar 3, 2014 at 3:14
  • Keep in mind that having a single connection will prevent you from running queries in multiple threads. Also - opening a new connection when you need to make a db call is a safer/easier pattern, imo; measure a performance hit of opening/closing connections and make a decision whether it actually impacts perceived performance. Commented Mar 3, 2014 at 17:08