Return `sqlStateSQL` or `sqlStateSQL99` (they are equal) from `DatabaseMetaData.getSQLStateType()`. Now the value is 0, which is not correct. Use SQLSTATE codes in SQLException where appropriate. Use categorized SQL exceptions where possible: * SQLNonTransientException * SQLTransientException * SQLRecoverableException Consider also using of BatchUpdateException and SQLClientInfoException. Test all this new stuff. See also: https://docs.oracle.com/javase/tutorial/jdbc/basics/sqlexception.html This issue is mostly optional (AFAIU), but `DatabaseMetaData.getSQLStateType()` should provide a correct value.