posted 12 years ago
Maybe this belongs in another forum; sorry if I picked the wrong one. This is a DAO. This is the original code that FindBugs reported may fail to close database objects.
I see lots of problems with this code but most important is the lack of a finally block. I won't even go into the use of Vector, hard coded database credentials (removed to protect the guilty) and concatenating Strings inside a loop. My main concern is leaving database resources open. I'll fix the other issues later. For now, I changed it to this:
This is modeled after other DAOs I've written which FindBugs doesn't complain about. However, Findbugs is telling me that this code may still fail to close a database resource. It looks to me like the finally block should close everything no matter how the method exits. What am I missing?
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson