• 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

Connection Pool

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have code which creates a connection fetches data from server and closes the connection, the application is to run above logic in a loop of 10,000 and above. I same facing a problem of connections not getting closed properly. Do anyone has idea of connection pooling?.
one solution we found is maintain a single connection and use the same throughout the apllication, but here the problem is if we are not using the port for a particular duration the system is not able to recognise the port no.. thanks in advance
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What sort of connection is this that you are talking about?
Whether you can use a single connection for all the clients depends on whether your connection is thread safe(which most of the connections are not).
If the connection can support multiple threads then everything should be fine.
However, for closing the connection you would have to find out whether there is any client using it. There are a few ways of doing this, if you are interested we can discuss this further.

If connection is not threadsafe then you have to have one connection per client. For this, as you have pointed out, you can use a connection pool. However, if your code does not know when to close the connection then in all possibilities connection pool also will not help.

My point is that if your problem is a connection leak then you need to fix your code that creates and releases connections. If your problem is time/memory taken for connection creation/limiting number of connections then you should look at connection pools.

JDBC connection pools are provided with all app/web servers. Google for connection pool and you would get numerous links.
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic