Find if an SQLException was thrown because of a duplicate

前端 未结 9 2588
青春惊慌失措
青春惊慌失措 2021-02-19 11:01

I have a Java program that is agnostic from the database and I need to know, while inserting, if an SQLException was thrown because of a duplicate key.

If I was using a

9条回答
  •  一生所求
    2021-02-19 11:38

    Am I missing something? If you're using JDBC you should get back a duplicate key exception, regardless of the DB being used.

    Or did you ask how you would determine a dupkey BEFORE you tried teh insert?

提交回复
热议问题