if (!rs.wasNull())
if (type != CoreMessage.TYPE)
   public List getMessages(List messageIds) throws Exception   {      if (trace)      {         log.trace("Getting batch of messages for " + messageIds);      }            Connection conn = null;      PreparedStatement ps = null;      ResultSet rs = null;      TransactionWrapper wrap = new TransactionWrapper();            try      {         conn = ds.getConnection();                  Iterator iter = messageIds.iterator();                  int size = messageIds.size();                  int count = 0;                  List msgs = new ArrayList();                  while (iter.hasNext())         {            if (ps == null)            {               //PreparedStatements are cached in the JCA layer so we will never actually have more than               //100 distinct ones                           int numParams;               if (count < (size / maxParams) * maxParams)               {                  numParams = maxParams;               }               else               {                  numParams = size % maxParams;               }               StringBuffer buff = new StringBuffer(loadMessages);               buff.append("WHERE ").append(messageIdColumn).append(" IN (");               for (int i = 0; i < numParams; i++)               {                  buff.append("?");                  if (i < numParams - 1)                  {                     buff.append(",");                  }               }               buff.append(")");               ps = conn.prepareStatement(buff.toString());                              if (trace)               {                  log.trace(buff.toString());               }            }                        long msgId = ((Long)iter.next()).longValue();                        ps.setLong((count % maxParams) + 1, msgId);                        count++;                        if (!iter.hasNext() || count % maxParams == 0)            {               rs = ps.executeQuery();                              int innerCount = 0;                              while (rs.next())               {                  long messageId = rs.getLong(1);                  boolean reliable = rs.getString(2).equals("Y");                  long expiration = rs.getLong(3);                  long timestamp = rs.getLong(4);                  byte priority = rs.getByte(5);                  byte[] bytes = getLongVarBinary(rs, 6);                  HashMap coreHeaders = bytesToMap(bytes);                  byte[] payload = getLongVarBinary(rs, 7);                  int persistentChannelCount = rs.getInt(8);                                    //FIXME - We are mixing concerns here                  //The basic JDBCPersistencManager should *only* know about core messages - not                   //JBossMessages - we should subclass JBDCPersistenceManager and the JBossMessage                  //specific code in a subclass                                    byte type = rs.getByte(9);                                    Message m;                                    if (!rs.wasNull())                  {                     //JBossMessage                     String jmsType = rs.getString(10);                     String correlationID = rs.getString(11);                     byte[] correlationIDBytes = rs.getBytes(12);                     long destinationId = rs.getLong(13);                     long replyToId = rs.getLong(14);                     boolean replyToExists = rs.wasNull();                     bytes = getLongVarBinary(rs, 15);                     HashMap jmsProperties = bytesToMap(bytes);                     JBossDestination dest = cm.getJBossDestination(destinationId);                     JBossDestination replyTo = replyToExists ? cm.getJBossDestination(replyToId) : null;                                          m = MessageFactory.createJBossMessage(messageId, reliable, expiration, timestamp, priority,                           coreHeaders, payload, persistentChannelCount,                           type, jmsType, correlationID, correlationIDBytes, dest, replyTo,                           jmsProperties);                  }                  else                  {                     //Core message                     m = MessageFactory.createCoreMessage(messageId, reliable, expiration, timestamp, priority,                           coreHeaders, payload, persistentChannelCount);                  }                                    msgs.add(m);                  innerCount++;               }                              rs.close();               rs = null;                              ps.close();               ps = null;            }         }                  if (trace)         {            log.trace("Loaded " + msgs.size() + " messages in total");         }                  return msgs;      }      catch (Exception e)      {         wrap.exceptionOccurred();         throw e;      }      finally      {         if (rs != null)         {            try            {               rs.close();            }            catch (Throwable e)            {            }         }         if (ps != null)         {            try            {               ps.close();            }            catch (Throwable e)            {            }         }         if (conn != null)         {            try            {               conn.close();            }            catch (Throwable e)            {            }         }         wrap.end();      }   }  