Java – proper use of bonecp

I just started using bonecp and extracted JDBC code from the author's website

I have a function called getconnection (), which returns a connection as a code segment:

// setup the connection pool
BoneCPConfig config = new BoneCPConfig();
// Config goes here.
connectionPool = new BoneCP(config); // setup the connection pool

return connectionPool.getConnection(); // fetch a connection

Now, my question: 1) when I finish using the connection returned from the above function, I call connection Close() so that it returns to the pool, or close the connection completely? How do I return to the connection pool?

2) How do I clean up the application exit pool? When I finish, I call ConnectionPool Shutdown()? Also, I read somewhere that I need to close all pool connections separately? It's true?

thank you.

Solution

1. After completion, always call connection Close() returns the connection to the pool (it will not be physically closed)

2. Do not reconnect after completing the pool, please call ConnectionPool shutDown().

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>