Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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 ajoutée par Usama Saad , Senior Software Engineer (Java) , Saudi Catering Company
Date de publication: 2013/08/23
mirza habeeb
par 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

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?