Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在一个重复条目的环境中,我遇到了这样的异常
引起:com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:键 3 的重复条目“管理员”
在另一个环境中,我得到它喜欢
引起:com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:重复条目 'admin' 键 'username_UNIQUE'
可能是什么原因?
如您所见,它们的含义相同。似乎mysql人已经更改了错误消息。在新版本中,他们可能试图让他们的信息更容易理解和缩小范围。但正如您所看到的,他们没有更改异常类名称。他们只更改了解释性消息。因此,如果您想用谷歌搜索您的异常,您最好使用异常类名称而不是消息。
在这种情况下,第一条消息直接指向它面临违规的键的“值”,第二条消息指向键“列”。