connection pool and data source


I was reading about conenction pooling and data source as follows

Connection Pooling

Connection Pooling feature added in jdbc2 where no need to load the driver, create  the connection in code.
This connection can be created on the web/application server which java application will get based On  the server  specified  no of connection.

It will avoid overhead of establishing connection. There are administered objects to manage the database connections, to Provide connection sharing, security. Datasource is Administrated factory object that provides connections from connection pools.
to fetch the connection from connection pool to the java application.

Datasource also Binds to JNDI and need to be configured.

I have not understood clearly why, how, where we use connection pool and data source.
what are the administered objects. what is the factory they are referring.

Please advise.

Any links resources ideas highly appreciated. Thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

A connection pool is a pool of... connections!! What you do is you create several connections on server start up (the old way was to create a connection each time a user requested one), because creating a connection is an expensive operation in terms of time and resources.

So lets say that the server creates a pool named "myPool" that has 20 database connections in. But how do you get a connection from the "myPool"? That's where a datasource comes into play. You use a datasource in order to obtain a connection from the pool.

what is the factory they are referring.
A factory is another way of creating objects. Instead of creating objects with the "new" keyword you use a factory that manages the creation of the objects. In your question a datasource is essentially a factory for the connections from the pool (but in our case it does not create the connections, it just gets one from the pool).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.