Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Why did the tomcat server come across some exceptions thrown frequently in some part of the code?

When I examined the code, this what it looked like public static String doSomething() { String returnVakue = "default value"; try { ResultSet rs = getMyResultSet(); rs.first(); returnValue = rs.getString("my_field"); // Note that Exception happens at times when the ResultSet is empty } catch (Exception e) { throw new Exception(e); } finally { return returnValue; } } While I am aware that it is perfectly OK to have both throws exception and return, wondering if this can cause any kind of leaks in tomcat. And Is there any potential risk with performance. ? Hoowever my caller function stops the execution at this point. Any views on this? Does it affect the GC? EDIT : NOTE : Please share your views whether this can potentially cause tomcat hanging.

user-image
Question added by Usama Saad , Senior Software Engineer (Java) , Saudi Catering Company
Date Posted: 2013/08/23
mirza habeeb
by mirza habeeb , Application Support & Database Developer , Via Technology

It doesn't close() the ResultSet, an possibly not the JDBC connection either.
This will pile up and you'll eventually run out of memory or slow down your database

More Questions Like This