课程: Learning JDBC
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Connection pooling and management
- [Instructor] In all of our examples, we've been getting a connection as a single instance, but in the real world, we actually build pools of connections and manage multiple connections to the database at once, handing each thread a connection from the pool when it is needed. So let's talk a little bit about that. So at its high level, connection pooling is a common data access pattern. We do this all the time, especially in web applications. What we can do is we can build a pool of connections and reuse those from request to request, much in the same way that we have done, but we've been working in a single-threaded environment. In the real world, we do these things in multi-threaded processing. It sort of works as a cache of all of our connections, and that's the important point is when you're done, it drops the connection back into the pool for the next use. And when you run out of connections, most of the pooling technologies will simply execute our routine to give you another…