Program: 80436
Project: 80436
Buggy source:
private void _runSelect(Connection conn,DaoStatement st) throws SQLException {
  Object[][] paramMatrix=st.getParamMatrix();
  int startRow=-1;
  int lastRow=-1;
  if (st.getContext().getResultSetType() == ResultSet.TYPE_SCROLL_INSENSITIVE) {
    Pager pager=st.getContext().getPager();
    if (pager != null) {
      startRow=pager.getOffset();
      lastRow=pager.getOffset() + pager.getPageSize();
    }
  }
  String sql=st.toPreparedStatement();
  if (log.isDebugEnabled())   log.debug(sql);
  ResultSet rs=null;
  Statement stat=null;
  try {
    if (null == paramMatrix || paramMatrix.length == 0 || paramMatrix[0].length == 0) {
      stat=conn.createStatement(st.getContext().getResultSetType(),ResultSet.CONCUR_READ_ONLY);
      if (lastRow > 0)       stat.setMaxRows(lastRow);
      if (st.getContext().getFetchSize() > 0)       stat.setFetchSize(st.getContext().getFetchSize());
      rs=stat.executeQuery(sql);
    }
 else {
      if (paramMatrix.length > 1) {
        if (log.isWarnEnabled())         log.warnf("String_Node_Str",paramMatrix.length - 1,st);
      }
 else       if (log.isDebugEnabled()) {
        log.debug(st);
      }
      ValueAdaptor[] adaptors=st.getAdaptors();
      stat=conn.prepareStatement(sql,st.getContext().getResultSetType(),ResultSet.CONCUR_READ_ONLY);
      if (lastRow > 0)       stat.setMaxRows(lastRow);
      for (int i=0; i < paramMatrix[0].length; i++) {
        adaptors[i].set((PreparedStatement)stat,paramMatrix[0][i],i + 1);
      }
      rs=((PreparedStatement)stat).executeQuery();
    }
    if (startRow > 0)     rs.absolute(startRow);
    st.onAfter(conn,rs);
  }
  finally {
    Daos.safeClose(stat,rs);
  }
  if (log.isTraceEnabled())   log.trace("String_Node_Str");
}

Fixed version (ground truth):
private void _runSelect(Connection conn,DaoStatement st) throws SQLException {
  Object[][] paramMatrix=st.getParamMatrix();
  int startRow=-1;
  int lastRow=-1;
  if (st.getContext().getResultSetType() == ResultSet.TYPE_SCROLL_INSENSITIVE) {
    Pager pager=st.getContext().getPager();
    if (pager != null) {
      startRow=pager.getOffset();
      lastRow=pager.getOffset() + pager.getPageSize();
    }
  }
  String sql=st.toPreparedStatement();
  ResultSet rs=null;
  Statement stat=null;
  try {
    if (null == paramMatrix || paramMatrix.length == 0 || paramMatrix[0].length == 0) {
      if (log.isDebugEnabled())       log.debug(st);
      stat=conn.createStatement(st.getContext().getResultSetType(),ResultSet.CONCUR_READ_ONLY);
      if (lastRow > 0)       stat.setMaxRows(lastRow);
      if (st.getContext().getFetchSize() > 0)       stat.setFetchSize(st.getContext().getFetchSize());
      rs=stat.executeQuery(sql);
    }
 else {
      if (paramMatrix.length > 1) {
        if (log.isWarnEnabled())         log.warnf("String_Node_Str",paramMatrix.length - 1,st);
      }
      if (log.isDebugEnabled()) {
        log.debug(st);
      }
      ValueAdaptor[] adaptors=st.getAdaptors();
      stat=conn.prepareStatement(sql,st.getContext().getResultSetType(),ResultSet.CONCUR_READ_ONLY);
      if (lastRow > 0)       stat.setMaxRows(lastRow);
      for (int i=0; i < paramMatrix[0].length; i++) {
        adaptors[i].set((PreparedStatement)stat,paramMatrix[0][i],i + 1);
      }
      rs=((PreparedStatement)stat).executeQuery();
    }
    if (startRow > 0)     rs.absolute(startRow);
    st.onAfter(conn,rs);
  }
  finally {
    Daos.safeClose(stat,rs);
  }
  if (log.isTraceEnabled())   log.trace("String_Node_Str");
}