Java + MySQL integrity violation handling

后端 未结 3 1202
日久生厌
日久生厌 2021-01-06 03:14

I write Java program using JDBC (mysql database). When I violate mysql integrity (f.e. I try to insert same primary key value) I catch SQL exception. Should

3条回答
  •  情书的邮戳
    2021-01-06 03:58

    There are two possible answers :

    • if you know that your application is designed to avoid this kind of behaviour, use the exception
    • if your application can make these errors often, use a test.

提交回复
热议问题