You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by navrsale <na...@yahoo.ca> on 2007/01/12 01:20:29 UTC
getFailingSqlStatement()
hi all,
if a single batch has a failed insert statement my understanding is that
remaining statements in the batch will be attempted and then BatchException
will be thrown? If in these remaining statements another statement(s) fails,
how can we get all sql statements that failed in the same batch? I guess
getFailingSqlStatement() returns only the first sql statement that failed in
a batch?
Many thanks,
--
View this message in context: http://www.nabble.com/getFailingSqlStatement%28%29-tf2962806.html#a8289571
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: getFailingSqlStatement()
Posted by Chris Lamey <cl...@localmatters.com>.
Last I checked, the JDBC spec left this behavior up to the driver, but
only the MySQL driver actually tries anything after the first exception
(and you had to explicitly turn that feature on). So I think every
other JDBC driver bails on the whole thing after the first Exception.
At least, that's the way I remember it a year or so ago.
You might want to check your JDBC driver's documentation and see what it
actually does with exceptions in batches, but it looks like iBATIS will
roll back on the first exception regardless.
SqlMapClient.executeBatchDetailed() will report back all the successful
executes prior to any exception, but stops at the first exception.
Here's what the Oracle JDBC docs say for their Standard JDBC Batching:
"...if there were 20 operations in the batch, the first 13 succeeded,
and the 14th generated an exception, then the update counts array will
have 13 elements, containing actual update counts of the successful
operations."
There was a big thread on this a while back, you might want to go read
the mail list archive to get the history of
SqlMapClient.executeBatchDetailed().
Cheers,
Chris
On Mon, 2007-01-15 at 18:12 -0800, navrsale wrote:
> But if that is so, why do we have:
>
> int[] rowCounts = be.getBatchUpdateException().getUpdateCounts();
>
> where be is BatchException
>
> My understanding is this will give all the "wrong" and "good" statements in
> a batch, will it not? (which means all the remaining statements in the batch
> will be attempted by the driver).
>
>
> Jeff Butler-2 wrote:
> >
> > Any failed statement ends the entire batch. If there is more than one
> > "sub
> > batch", everything is rolled back and nothing further is attempted.
> >
> > So there will only be one statement that kills the batch - the first one
> > that failed.
> >
> > Jeff Butler
> >
> >
> >
> > On 1/11/07, navrsale <na...@yahoo.ca> wrote:
> >>
> >>
> >> hi all,
> >>
> >> if a single batch has a failed insert statement my understanding is that
> >> remaining statements in the batch will be attempted and then
> >> BatchException
> >> will be thrown? If in these remaining statements another statement(s)
> >> fails,
> >> how can we get all sql statements that failed in the same batch? I guess
> >> getFailingSqlStatement() returns only the first sql statement that failed
> >> in
> >> a batch?
> >>
> >> Many thanks,
> >> --
> >> View this message in context:
> >> http://www.nabble.com/getFailingSqlStatement%28%29-tf2962806.html#a8289571
> >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
Re: getFailingSqlStatement()
Posted by navrsale <na...@yahoo.ca>.
But if that is so, why do we have:
int[] rowCounts = be.getBatchUpdateException().getUpdateCounts();
where be is BatchException
My understanding is this will give all the "wrong" and "good" statements in
a batch, will it not? (which means all the remaining statements in the batch
will be attempted by the driver).
Jeff Butler-2 wrote:
>
> Any failed statement ends the entire batch. If there is more than one
> "sub
> batch", everything is rolled back and nothing further is attempted.
>
> So there will only be one statement that kills the batch - the first one
> that failed.
>
> Jeff Butler
>
>
>
> On 1/11/07, navrsale <na...@yahoo.ca> wrote:
>>
>>
>> hi all,
>>
>> if a single batch has a failed insert statement my understanding is that
>> remaining statements in the batch will be attempted and then
>> BatchException
>> will be thrown? If in these remaining statements another statement(s)
>> fails,
>> how can we get all sql statements that failed in the same batch? I guess
>> getFailingSqlStatement() returns only the first sql statement that failed
>> in
>> a batch?
>>
>> Many thanks,
>> --
>> View this message in context:
>> http://www.nabble.com/getFailingSqlStatement%28%29-tf2962806.html#a8289571
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/getFailingSqlStatement%28%29-tf2962806.html#a8383318
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: getFailingSqlStatement()
Posted by Jeff Butler <je...@gmail.com>.
Any failed statement ends the entire batch. If there is more than one "sub
batch", everything is rolled back and nothing further is attempted.
So there will only be one statement that kills the batch - the first one
that failed.
Jeff Butler
On 1/11/07, navrsale <na...@yahoo.ca> wrote:
>
>
> hi all,
>
> if a single batch has a failed insert statement my understanding is that
> remaining statements in the batch will be attempted and then
> BatchException
> will be thrown? If in these remaining statements another statement(s)
> fails,
> how can we get all sql statements that failed in the same batch? I guess
> getFailingSqlStatement() returns only the first sql statement that failed
> in
> a batch?
>
> Many thanks,
> --
> View this message in context:
> http://www.nabble.com/getFailingSqlStatement%28%29-tf2962806.html#a8289571
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>