• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to achieve Connection polling in JDBC

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my app code i am, for each and every method i am taking a Jdbc Connection( defined as a singleton class) using it and at the end of every method i am closing it.
Overall there is lots og conection opening and closing in that file. How can i get rid ofthis frequent opening and closing of connection.
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't reinvent the wheel. Most application servers provide a mechanism for creating and managing connection pools. In such a scenario, you then request a connection from the data store and it will give you one if its open. Check the documentation for whatever application server you are using to see how to establish connection pools.
 
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scott,

Could you please tell me if the application is POJO (simple java class). We can't use application server datasource. In this case how to make use of Connection and data source.

As of my knowledge we can achieve this by Apache commons rite
by using
1. commons-dbcp.jar
2. commons-pooljar
3. commons-collections.jar

Is their any other alternative for connection pool and datasource usage in standalone Java application.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic