Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
585 views
in Technique[技术] by (71.8m points)

database - What is the benefit of Connection and Statement Pooling?

Can someone explain what is Connection and Statement Pooling and what is the benefit over unpooled DataSources? I am trying to understand when it is a good idea to use a technology like c3p0 or proxool in a project. I need first to understand what they do and when it interesting to use them. Thank you very much.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The Happy Connection

It's so easy to create a new connection every time. One line: that's all it takes. Nothing much to think about. Great life.

Hold on. Do you eat on a plate?

enter image description here

Do you throw away your plate after each use?

No, you wash it and put it on the dish rack, so you can use it again on your next meal. Buying new plates everytime is out of the question. If you did that, you will have wasted enough money to buy a new iPad in one year.

Think about connection pools again.

But this time, the connections are your plates, the connection pool is your dish rack. Your wallet and your energy represent the system resources (memory and bandwidth).

Wash or Spend?

What would you rather do:

a. wash the dishes

b. or run to the mall every meal and buy new plates?

While there are tasks involved in connection pooling, it's less taxing in the long run compared to creating new connections every time. The key is in knowing how many plates (connections) your family (application) will need in any given day.

Pools can be used for database connections, threads, entity beans and other factory-derived objects.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...