You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Stephen Letschin <st...@media.umbc.edu> on 2003/08/22 21:35:27 UTC

Standard Taglib - Catching a SQL:DataSource

I am attempting to use a c:catch around a sql:setDataSource with a JDNI
defined dataSource to ensure connectivity with the database exists. It
appears however that the c:catch is not working in this instance.
The code looks something like:

<c:catch var="databaseError">
    <sql:setDataSource dataSource="validJNDIDataSource" />
</c:catch>

I know the sql:setDataSource works fine but in my testing when I used an
invalid dataSource (which should through a JSPException), I actually get a
ServletException and the catch does not seem to work.
I found a bug #8366 report that seems to indicate that while
sql:setDataSource throws a JSPException while dataSource is null (which it
is not in this case) but the actual initialization exception will be
thrown on a subsequent sql:update or sql:query. Is this the intended
behavior and why my code isn't working? This seems like a poor design
decision if it is since it seems to prevent using one error handling
approach for a non-contactable database and a second for just bad data
(like selecting from a table that doesn't exist). You might be able to use
some Java scriptlet to parse the actual Exception thrown and determine if
it is the database vs the data but that seems to defeat the purpose of the
c:catch tag to avoid those type scriptlets.
Anyone have any thoughts?

Stephen Letschin
stephen@media.umbc.edu