There will definitely be an effort to tighten up error handling in DBTags (or son of 
DBTags).  We're still unsure of what technique to use.  Manually insertinq a try/catch 
block is certainly not an appealinq option for the JSP author!  We could have every 
tag close the current connection(s) in the event of a problem, but that would only 
catch problems originating from one of our tags.  There are some other possible 
solutions, which we'll be exploring soon.

Morgan

Ciot, Thierry wrote on 7/20/01 3:43 pm:

>When using DBTag, how can I 
>ensure that a connection is 
>closed if an exception 
>condition occurs?
>
>It seems the only way is to 
>enclose each DBTag lib usage 
>with try, catch.
>
>It looks like the attached 
>code below (which is not 
>really pretty).
>
>Is there another way to do 
>it?
>
>Could the tag library ensure 
>the connection is closed? We 
>could for example, have all 
>jdbc tag operations within 
>the body of the connection 
>tag and thus reaching the 
>end of that tag would mean 
>close connection?
>
>By the way, it is not possible 
>to enclose everything in a 
>try finally block: for some 
>reasons I don't understand 
>yet Tomcat complains about 
>"javax.servlet.ServletExcept
>ion:  _jspService signature 
>(Ljavax/servlet/http/HttpS
>ervletRequest;Ljavax/servl
>et/http/HttpServletRespo 
>nse;)V) Incompatible object 
>argument for function call"
>
>Thanks in advance, Thierry.
>
><%
>try
>{
>%>
><h1>Testing JDBC</h1>
><h2>Opening 
>connection</h2>
><jdbc:connection 
>id="conn1">
><jdbc:url>jdbc:odbc:test</jd
>bc:url>
><jdbc:driver>sun.jdbc.odbc.J
>dbcOdbcDriver</jdbc:driver
>>
></jdbc:connection>
>
><%
>} // end try
>catch ( Exception e )
>{
>%> 
>
><h2>Closing the database 
>connection</h2>
><jdbc:closeConnection 
>conn="conn1"/>
>
><%
>} // end catch
>%>
>
><h2>Closing the database 
>connection</h2>
><jdbc:closeConnection 
>conn="conn1"/>

Reply via email to