Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Weak reference concept in Connection

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have the folowing code snippet


My doubt is
1) I do a getConnection two times but should I close two times using returnConnection or one returnConnection is enough.
2) I read about a concept called "Weak reference".Does this example point to that.Any more simplified explanation availabe
for the concept somewhere.
3) As of now , I have used two return connection (i have uncommented the code in the finally to avoid problems)but I feel its redundant.Please correct me if am wrong.
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
next time post a clean and idented code

Googling you'll find nice texts about weak references. But I don't think you need to use it.
Search for connection pool to enhance the performance.

yes, it's redundant. other thing I noticed, you are throwing and catching the exception in the same
method.

I changed the code a little:

 
siva saran
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Leandro. I will keep your instruction in mind.
 
The only thing that kept the leeches off of me was this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic