When you call a store procedure the store procedure will execute in database server so if there any exception occurs that can be handled in EXCEPTION block in the store proc. If the store procedure it self fails it throws sql exception which can be handled by try/catch block and wrap it to your project specific exception.
example
try {
CallableStatement stmt=con.prepareCall("{call geNamebyId(?)}");
stmt.setInt(1,123);
stmt.execute();
} catch(SQLException e) {
e.printStack();
throw new CustomException(e);//application specific exception
}
example
try {
CallableStatement stmt=con.prepareCall("{call geNamebyId(?)}");
stmt.setInt(1,123);
stmt.execute();
} catch(SQLException e) {
e.printStack();
throw new CustomException(e);//application specific exception
}
Post a Comment