简体   繁体   中英

when to use a db connection pool

I am working on a Java GUI and I often need to connect to the database,but I would like to only use the connection statements once,instead of writting the whole thing everytime i use it. I guess I would probably connect around 20 times in my whole system. So I wanted to know in which situation it is best to use Connection Pool?

Typically a connection pool is used when there are multiple threads requiring access to the database at the same time (a web application for example), each would retrieve a connection from the pool and return it when it's finished executing.

Typically GUI applications wouldn't require the amount concurrent DB access that warrants a connection pool, and a single (static) connection that is initialised when the application starts would normally suffice.

I hope this points you in the right direction; without knowing more about the nature of the application that you're creating it's difficult to make a more informed decision!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM