posted 16 years ago
Paul, Jeanne, you're right. The end user shouldn't know what is going on during the insert. But during the transaction, if it throw a SQLException, I need to know what caused this exception to do something (it can be show a friendly message for example). SQLException is generic, it can be caused by a PK, FK, UK... The unique way that I found was getting SQLException.getErrorCode(). For example, the code 1 (for the Oracle) is Primary Key Violation... In DAO classes I throw an especified exception depending the getErrorCode(). Like this:
The interface will call this method and implement the PKException:
Did you understand me? Now I want to know: Is it the best way? There are something newer than this solution?
Tahnks.
Dadonas<br /> <br />Don't gain the world and lose your soul.