Come catturare Sybase RaisError in Mybatis-Spring?
Domanda
Sto cercando di acquisire messaggi di errore nel mio codice Java da procedure memorizzate in Sybase utilizzando RAISERROR
, ma non viene catturato nulla, anche se quando chiamo Direttamente PROC posso vedere l'errore viene lanciato.
Capisco che mybatis-molla
.traduce le eccezioni mybatis in molla dataccessException
Quindi ho codificato in breve la mia classe Mapper:
void insertData(Data toInsert) throws Exception, DataAccessException;
.
Sto cercando di catturare entrambe queste eccezioni, ma non viene catturato nulla.
Qualcuno ha qualche idea?
Grazie, Stephen
Soluzione
Ho scoperto come farlo:
try {
myMapper.insertData(data);
}
catch (org.springframework.jdbc.UncategorizedSQLException e) {
Throwable ee = use.getCause();
// getMessage on chained exception gets message from RAISERROR
log.error(ee.getMessage(), e);
}
.
Cheers, Stephen
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow