db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Myrna van Lunteren <m.v.lunte...@gmail.com>
Subject Re: derby error checking ???
Date Sat, 18 Jun 2005 19:52:14 GMT
On 6/18/05, jacob Lloyd (Gmail) <jacob.jll@gmail.com> wrote: 
> Hello all,
> I'm reviewing derby and hsqldb to decide which embedded database will
> best fit the projects needs (using as an alternative to ms-access). 
> The question is, in derby when using the ij tool to run automated
> scripts or in server-side procs or triggers, how do you check errors
> statuses/SQLStates?
> For example if an INSERT fails I don't want to continue the balance of 
> the script. I've looked in the all of the manuals and have 'googled'
> this topic and have found nothing.
> Sincerely,
> Jacob
Hi Jacob,
The typical way you'd approach a failure returned from a JDBC-call 
(statement, preparedStatement, callableStatement, etc) is to catch the 
SQLException. You can probably find plenty of examples in any JDBC book.
A statement that would fire a trigger would still fail with an SQLException.
 If you're talking about ij, and plain SQL-scripts - well, how about setting 
autocommit off at the top and back on at the end of the SQL you want to be 
committed or rolled back as a whole? Just let the transaction logic take 
care of things that way without need to manually? It would work for the 
insert example you give.

View raw message