Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to implement connection pooling in java?
give me helping code..
Posted

1 solution

java Provide DataSource class javax.sql.DataSource, using this we can look up for the JNDI created in the application server.

No need to create the pool using java. the pool can be created on the application server, and access it using the JNDI name.

If you really want to create your own connection pool using java, you an do so, by putting all the require parameters in a property file like max connections, min connections, DB connection details, and the max ideal time.

And then write a code, like at a given time how many connections are required, create that may connection and put the connection id (for your reference) and connection object in hashmap, here you need to keep track which connection is used, whenever user makes the request. and also its ideal time. When the min connection are busy then you need to create a new connection for more demand and give it to user.

The above mention details is only an overview.

But i suggest to use the connection pool facility provided by the server rather than creating your own.

Hope this info helps you.

Regards,
Panduranga.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900