This is probably very silly to ask, but I'm facing this situation:
I have a table that I'm populating every time a user sends a request, I'm using the date on one the fields (a date) from the last row I inserted. The problem is, the last row I inserted is always going to try and insert itself because it is in the range I'm considering. I know a solution is probably just adding a minute or two to the last row, but from this my question comes. How can I in java, using a PreparedStatement and a batch to insert multiple rows, skip the ones that send me that PRIMARY_KEY_VIOLATION exception, and keep inserting the ones that are ok? I mean, for instance, I have in my table a row "runner" with the value 25, and that's my primary key, and then I want to insert these rows: (25,26,27) The 25 values cannot be inserted, so I want to catch the exception and do something to keep inserting the 26 and 27 values. Is it possible?
I appreciate your help and comments. Thank you in advance!