Program: 43256
Project: 43256
Buggy source:
public void exec(Connection conn,DaoStatement st){
  Object[][] paramMatrix;
  try {
    st.onBefore(conn);
switch (st.getSqlType()) {
case SELECT:
      paramMatrix=st.getParamMatrix();
    if (null == paramMatrix || paramMatrix.length == 0 || paramMatrix[0].length == 0) {
      String sql=st.toPreparedStatement();
      if (log.isDebugEnabled())       log.debug(sql);
      Statement stat=null;
      ResultSet rs=null;
      try {
        stat=conn.createStatement(st.getContext().getResultSetType(),ResultSet.CONCUR_READ_ONLY);
        if (st.getContext().getFetchSize() > 0)         stat.setFetchSize(st.getContext().getFetchSize());
        rs=stat.executeQuery(sql);
        if (st.getContext().getResultSetType() == ResultSet.TYPE_SCROLL_INSENSITIVE) {
          Pager pager=st.getContext().getPager();
          if (pager != null) {
            rs.absolute(pager.getOffset());
          }
        }
        st.onAfter(conn,rs);
      }
  finally {
        Daos.safeClose(stat,rs);
      }
      if (log.isTraceEnabled())       log.trace("String_Node_Str");
    }
 else {
      String sql=st.toPreparedStatement();
      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();
      PreparedStatement pstat=null;
      ResultSet rs=null;
      try {
        pstat=conn.prepareStatement(sql,st.getContext().getResultSetType(),ResultSet.CONCUR_READ_ONLY);
        for (int i=0; i < paramMatrix[0].length; i++) {
          adaptors[i].set(pstat,paramMatrix[0][i],i + 1);
        }
        rs=pstat.executeQuery();
        st.onAfter(conn,rs);
      }
  finally {
        Daos.safeClose(pstat,rs);
      }
      if (log.isTraceEnabled())       log.trace("String_Node_Str");
    }
  break;
case ALTER:
case TRUNCATE:
case CREATE:
case DROP:
_runStatement(conn,st);
st.onAfter(conn,null);
break;
case RUN:
st.onAfter(conn,null);
break;
default :
paramMatrix=st.getParamMatrix();
if (null == paramMatrix || paramMatrix.length == 0) {
_runStatement(conn,st);
}
 else {
_runPreparedStatement(conn,st,paramMatrix);
}
st.onAfter(conn,null);
}
}
 catch (SQLException e) {
if (log.isInfoEnabled()) log.debug("String_Node_Str",e);
throw new DaoException(format("String_Node_Str",st.toString(),st.toPreparedStatement()),e);
}
}

Fixed version (ground truth):
public void exec(Connection conn,DaoStatement st){
  Object[][] paramMatrix;
  try {
    st.onBefore(conn);
switch (st.getSqlType()) {
case SELECT:
      paramMatrix=st.getParamMatrix();
    if (null == paramMatrix || paramMatrix.length == 0 || paramMatrix[0].length == 0) {
      String sql=st.toPreparedStatement();
      if (log.isDebugEnabled())       log.debug(sql);
      Statement stat=null;
      ResultSet rs=null;
      try {
        stat=conn.createStatement(st.getContext().getResultSetType(),ResultSet.CONCUR_READ_ONLY);
        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();
          }
        }
        if (lastRow > 0)         stat.setMaxRows(lastRow);
        if (st.getContext().getFetchSize() > 0)         stat.setFetchSize(st.getContext().getFetchSize());
        rs=stat.executeQuery(sql);
        if (startRow > 0)         rs.absolute(startRow);
        st.onAfter(conn,rs);
      }
  finally {
        Daos.safeClose(stat,rs);
      }
      if (log.isTraceEnabled())       log.trace("String_Node_Str");
    }
 else {
      String sql=st.toPreparedStatement();
      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();
      PreparedStatement pstat=null;
      ResultSet rs=null;
      try {
        pstat=conn.prepareStatement(sql,st.getContext().getResultSetType(),ResultSet.CONCUR_READ_ONLY);
        for (int i=0; i < paramMatrix[0].length; i++) {
          adaptors[i].set(pstat,paramMatrix[0][i],i + 1);
        }
        rs=pstat.executeQuery();
        st.onAfter(conn,rs);
      }
  finally {
        Daos.safeClose(pstat,rs);
      }
      if (log.isTraceEnabled())       log.trace("String_Node_Str");
    }
  break;
case ALTER:
case TRUNCATE:
case CREATE:
case DROP:
_runStatement(conn,st);
st.onAfter(conn,null);
break;
case RUN:
st.onAfter(conn,null);
break;
default :
paramMatrix=st.getParamMatrix();
if (null == paramMatrix || paramMatrix.length == 0) {
_runStatement(conn,st);
}
 else {
_runPreparedStatement(conn,st,paramMatrix);
}
st.onAfter(conn,null);
}
}
 catch (SQLException e) {
if (log.isInfoEnabled()) log.debug("String_Node_Str",e);
throw new DaoException(format("String_Node_Str",st.toString(),st.toPreparedStatement()),e);
}
}