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.
system.db.runPrepUpdate("Some Query",[value1, value2,...])
except Exception, e:
print "python exception : " + str(e)
except java.lang.Exception, e:
print "java exception: " + str(e)
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.