Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

finally method()

 
Richard Mendoza
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a program that connects to the database using postgres and using the tomcat 4 as the web server. Below is the structure that I created:

<%
Connection con;
...
...
try{
con = ...
}
catch(Exception e)
{
out.println("Error : "+e);
}
finally
{
con.close();
}

I am always prompted by an error in the finally block.
How do I resolve the problem?


%>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am always prompted by an error in the finally block.

Details regarding the error mght be useful.

bear
P.S. And of course I must deliver my obligatory admonition that performing database access directly from a JSP is not the best architecture you could pick.
[ January 28, 2004: Message edited by: Bear Bibeault ]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error you will be getting is that con.close can throw exceptions that you are not catching. It always seems wierd to me, but you have to do something like:

You may want to put some logging in the catch, but I'm not sure what (if anything) should be done if a "close" operation fails!
[ January 29, 2004: Message edited by: Frank Carver ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!