ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Winarto" <wina...@fermat.eu>
Subject RE: error handling in iBatis?
Date Tue, 12 May 2009 00:31:25 GMT


I believe you're using Spring-DAO with IBatis as ORM. The method
getSqlMapClientTemplate().queryForList is actually throwing
DataAccessException. However since it is inheritance of
RuntimeException, you do not need to explicitly catch it. But yes, you
can catch it if you want.






From: Bhaarat Sharma [mailto:bhaarat.s@gmail.com] 
Sent: Monday, 11 May 2009 23:27
To: user-java@ibatis.apache.org
Subject: error handling in iBatis?


we have been using iBatis for a while now.  


However, we do not perform any error handling while executing the sql
maps.  Back when we used java code to connect, we used try and catch
blocks.  Where the catch block would log an error message. 


something like this:


            try {

                Conn = getConnection(DataCollection.HEREMS);

                cstmt = Conn.prepareCall(storProc);

                cstmt.setString(1, user.toUpperCase());

                rs = cstmt.executeQuery();

                while (rs.next()) {

                    String roleId = rs.getString("role_code");



            }catch (SQLException ex) {


            }finally {

               try {

                  releaseConnection(Conn, cstmt, null, rs);

               }catch (SQLException ex) {





Now with sqlMaps we simply do something like this:




        if (paramMap.size() == 3)


            fmr = (FormerTenants) paramMap.get("single_tenant_results");




        return fmr;


In the above code we are expecting 3 resultsets so all we are doing is
checking if map size is 3.


What if some error happens while executing the stored procedure.  Where
will that error go?  Is there a way in iBatis to log error messages? I
would appreciate some sample which would point me in the right



View raw message