• 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

Closing DB issue in new method

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a method that inserts data into my Oracle 9i database with no problems and no Database closing issues:


Now when I put the method (inserter) in another class called OtherClass, it does insert the data but now I have database closing issues:



In my SQL Plus database resource check I see JDBC Thin Client is opened and not closed after each insert with the above attempt.
This didnt happen when I had the method in the same class.

Please advise.
[ October 15, 2007: Message edited by: Ed Carrington ]
 
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
Even though this probably sounds excessive, your finally code should be protected line by line as such:


I've seen people not do this in the past and keep in mind, if an rs.close() or stmt.close() fails then without this type of structure the conn.close() might not be executed.

If it helps I usually add these add as static utility functions so I don't have to write this over and over again.
 
Ed Carrington
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Scott Selikoff:
Even though this probably sounds excessive, your finally code should be protected line by line as such:


I've seen people not do this in the past and keep in mind, if an rs.close() or stmt.close() fails then without this type of structure the conn.close() might not be executed.

If it helps I usually add these add as static utility functions so I don't have to write this over and over again.




Thanks I added as you suggested and still have the database closing issue.
Please advise.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic