Hi all,

Thanks for your help. Upgrading is a huge job but it goes well so far. How can I have access to the ResultSet. Here I need performance so I need to access the resultSet directly. More I have 60+ reports that all access the resultSet directly.

Thanks for you help!

Regards
/David


   public synchronized void processDataChangeNotification() {
String sql = dbNotificationDao.getSqlMap().getMappedStatement(DbNotificationDaoX.NOTIFICATION_PREFIX + "." + WebOsConstants.DB_GET).getSql(null);
       DbConnection dbConDetail = null;
       // allow only one at a time
       try {

ConnectionFactory connectionFactory = (ConnectionFactory) ManagersFactory.getManager(ConnectionFactory.MANAGER_KEY);

           dbConDetail = connectionFactory.getConnection();
           dbConDetail.startTransaction();
           ResultSet detailRs2 = dbConDetail.executeQuery(sql);
           while (detailRs2.next()) {
               String entity = detailRs2.getString(1);
               cacheUpdateInfo.id1 = detailRs2.getString(2);
               cacheUpdateInfo.id2 = detailRs2.getString(3);
               cacheUpdateInfo.id3 = detailRs2.getString(4);
               cacheUpdateInfo.id4 = detailRs2.getString(5);
               cacheUpdateInfo.timestamp = detailRs2.getString(6);
CachedDao handler = (CachedDao) dataChangeHandler.get(entity);
               if (handler != null) {
                   handler.handleDataChange(entity, cacheUpdateInfo);
               } else {
log.error("No data change handler register for entity : " + entity);
               }
           }

           // delete processed notification
sql = dbNotificationDao.getSqlMap().getMappedStatement(DbNotificationDaoX.NOTIFICATION_PREFIX + "." + WebOsConstants.DB_DELETE).getSql(null);
           dbConDetail.execute(sql);

           dbConDetail.commitTransaction();

       } catch (SQLException e) {
log.error("Unable to write the db (EntitySerialiser): " + e.getMessage(), e);
       } finally {
           if (dbConDetail != null)
               dbConDetail.closeAll();
       }


   }





Clinton Begin wrote:
Using setUserConnection will work. It's thread safe, so don't worry about concurrent access. Just make sure to "unset" it by calling setUserConnection (null) -- which reminds me, we should add a clearUserConnection() to make this code nicer.

The other way to do it is with openSession (Connection conn). But I don't see a reason for you to do that here.

As for accessing the SQL statements themselves -- be warned, it will not be easy. iBATIS 2.0 does a lot more to keep you away from the guts of the framework to avoid upgrade issues...as you're experiencing now. ;-)

Let us know when you get to that point, we'll see what we can do.

public final List getList(DbConnection dbCon, String mapKey, Object param) throws DatabaseException { boolean handleTransactionLocally = false;
  try {
    if (dbCon == null) {
      handleTransactionLocally = true;
      dbCon = connectionFactory.getConnectio n();
      dbCon.setReadOnlyConnection(true);
    }
    sqlMap.setUserConnection (dbCon.getConnection());
    return sqlMap.queryForList(mapKey, param);
  } catch (SQLException e) {
    // log.error("Error during sql: " + e.getMessage(), e);

    ExceptionAdaptor.instance(exceptionAdaptorKey).getMappe dException(e,
"getList: " + e.getMessage(), true, ExceptionAdaptor.ACTION_SEARCH, param);
  } finally {
    sqlMap.setUserConnection(null);
    if (dbCon != null) {
      dbCon.closeAll(handleTransactionLocally);
    }
  }
}

Clinton




On 8/16/06, *David Gagnon* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Hi all,

    I'm having a lot of fun trying to convert my code to 2.1.7.  There is
    still a lot of things I didn`t figured out yet.

    Can you please tell me how to convert the following function.?


        public final List getList(DbConnection dbCon, String mapKey,
    Object
    param) throws DatabaseException {

            List list = null;
            boolean handleTransactionLocally = false;
            try {
                if (dbCon == null) {
                    handleTransactionLocally = true;
                    dbCon = connectionFactory.getConnection();
                    dbCon.setReadOnlyConnection(true);
                }

                MappedStatement statement =
    sqlMap.getMappedStatement(mapKey);
                list =
    statement.executeQueryForList(dbCon.getConnection(),
    param);
            } catch (SQLException e) {
    //            log.error("Error during sql: " + e.getMessage(), e);

    ExceptionAdaptor.instance(exceptionAdaptorKey).getMappedException(e,
    "getList: " + e.getMessage(), true,
    ExceptionAdaptor.ACTION_SEARCH, param);
            } finally {
                if (dbCon != null) {
                    dbCon.closeAll(handleTransactionLocally);
                }
            }
            return list;
        }



    I saw a sqlMap.setUserConnection() but this method can be called by
    simultaneously so setting the connection in the sqlMap doesn`t make
    sense to me.  There is probably something that I don`t understand!

    Please help :-)

    Best Regards.
    /David
    P.S.: Also I do need to get the SQL string from a map to play with it
    myself.  I'm not there yet but I hope there a way to get it!  Thanks







Reply via email to