• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 607
  • Last Modified:

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
1 Solution
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).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now