Hi Matthias,

I'm very sorry for the delay in my answer. This conversation must have
slipped through somehow.

Indeed, the Loader API has a more explicit way to access errors than the
batch update, which returns only the JDBC int[]. There's a way to access
the JDBC exceptions through JDBC directly. You could implement an execute
listener and then access the PreparedStatement after execution.

In your case, however, an update that updates no rows is completely valid.
It's not an error - it might be an expected situation. Unless you're
perhaps using the optimistic locking feature in jOOQ and expected that
update to always work? In that case, there's indeed a known issue:
https://github.com/jOOQ/jOOQ/issues/1637

Does this help?
Best Regards,
Lukas

2016-09-22 10:19 GMT+02:00 matscheer via jOOQ User Group <
[email protected]>:

> Hello Lukas,
>
> we use mssql Server. I expected a exception if i make an update and the
> expected primary key does not exist...
> But mssql and postgres tells the user only that "0 rows affected"... so
> there is no error ~~
>
> The Loader Api (we use it for inserts) returns a List of LoaderError this
> feels quite easier to handle.
>
> This is the implementation for batchUpdate:
>
> for (int i = 0; i < execute.length; i++)
> {
>     if(execute[i] == 0)
>         LOGGER.log(Level.SEVERE, String.format("Error while update :\n %s", 
> records.get(i).toString()));
> }
>
>
> And this is the implementation for LoaderApi:
>
> List<LoaderError> errors = executeResult.errors();
>
> if (!errors.isEmpty())
> {
>     errors.forEach(loaderError -> LOGGER.log(Level.SEVERE, "Error while 
> writing to database"
>             , loaderError.exception()));
> }
>
>
> Do you have some advises or is this the right way to handle errors in the
> respective api's?
>
> Cheers,
> Matthias
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to