----- Original Message ----- From: "Johnny Kewl" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Tuesday, September 16, 2008 5:41 PM
Subject: Re: Tomcat 5.5, JNDI Connection Pooling, Active connections keep increasing....



----- Original Message ----- From: "Brantley Hobbs" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Tuesday, September 16, 2008 5:27 PM
Subject: Re: Tomcat 5.5, JNDI Connection Pooling, Active connections keep increasing....


"return" statements do not prevent the finally block from executing:

http://java.sun.com/docs/books/tutorial/essential/exceptions/finally.html

I stand corrected...
Always understood as "during exception handling"... but you right it seems

I just cant bring myself to write code like that... feels un-natural...

I would still put return after the close... apologies...


Ok sinoea, what I thought was just s little slip turns out to be right... I actually tested it... that finally does run as the method loses scope... I actually wonder how they do that... I imagine a destructor in a C class underneath Java... its interesting, but I got to tell you, you doing the all the good text bokk stuff, but the code makes me feel uncomfortable... mmmm

Anyway... I think you got a threading problem...
You using static class and servlets are multithreaded....

Rather do something like this...

Collection<Branch> branches = new BranchData().loadBranches(Data.getDataSource(), 1);

and get rid of the static methods in that BranchData class....

ie make it thread safe... at the moment you have multiple threads in that static method... and with that finally I really dont know... haha

and then...

results.close();
statement.close();
connection.close();
return branches;

Would make me happy... and handle those exceptions

               } catch (SQLException e) {
branch.setErrorMsg("Dear User, you have run out of connections");
               }finally{
                   //absolute critical stuff
               }


But that really is just a style thing from the looks of things... although I do think that with just a finally, you will still get a ungly servlet exception... ie you are definitely cleaning up... but you not telling the user why... its style

You doing all the good stuff... but more important even if you forget a final or two... is just a nice clean readable flow... I think ;)

We have a style clash.... ;)

Anyway thing your problem may go away once its thread safe ;)

Thanks... learnt something ;)
Will keep guessing till we get it ;)
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to