This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!
See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

what is a connection?

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recently one of our legacy applications was changed from a non-pooling data source to one that pools. Immediately connection leaks started. This made me realize that Java was garbage collecting the unclosed connections when the non-pooling data source was being used. With the pool calling close() on a connection was required to move it back to the pool. If close() was not called the connection was leaked, i.e. never usable again but also never garbage collected.

This has me asking myself what is a connection in physical terms? Is a connection just an object so a connection leak is a memory leak? Or does a connection encapsulate some other finite resource that can be used up faster than available memory can be used up.

I've been using Connection for years and never really thought about this.

-=beeky
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by William Stafford:
...Is a connection just an object so a connection leak is a memory leak? Or does a connection encapsulate some other finite resource that can be used up faster than available memory can be used up....

It holds finite resources: an active connection to the database. These objects consume resources on client side (in your connection pool), but also in the database server. PMD can help you to find situations where you don't close a connection.

Regards, Jan
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to add something on similar notes. If you use datasource.xml file you need to define minimum number (5 for exp) of connections and maximum number (25 for exp) of connections. The moment you start your app server, it makes 5 physical connection originating from the machine where app server is running. I have had my DBA calling me about persistant connections and asking me why do I have those connection open all the time.

It also plays a tricky licensing issues. You can have just 5 Oracle licenses and you can make a web app where 50 users are using those 5 connections through web app. My 2 cents.
reply
    Bookmark Topic Watch Topic
  • New Topic