Is there a way to gracefully exit a function if some type of SQL statement fails such as runPrepQuery or runPrepUpdate? I am getting errors sometimes due to database primary keys/foreign key relationships and I don’t want to “exit” the function, I just want the statement to be skipped over.
Note that if you specify the generic python Exception class in your except clause, you won't catch java-specific exceptions. You would need an extra except clause:
Just to go off what pturmel said, if you are getting primary key/foreign key relationship and otherwise integrity errors, those ARE java errors which will need a specific catch.
However, if you are getting errors with foreign keys/primary keys, I would also take another look at your database design and see what is going on. Some constraints were obviously put on the tables for data integrity reason and it will only help your code to know what they are/why certain things are failing.