Program: 80631
Project: 80631
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);
        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 DELETE:
case UPDATE:
case INSERT:
paramMatrix=st.getParamMatrix();
if (null == paramMatrix || paramMatrix.length == 0) {
_runStatement(conn,st);
}
 else {
_runPreparedStatement(conn,st,paramMatrix);
}
st.onAfter(conn,null);
break;
case TRUNCATE:
case CREATE:
case DROP:
_runStatement(conn,st);
st.onAfter(conn,null);
break;
case ALTER:
case RUN:
st.onAfter(conn,null);
break;
default :
throw Lang.impossible();
}
}
 catch (SQLException 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);
        if (st.getContext().getFetchSize() > 0)         stat.setFetchSize(st.getContext().getFetchSize());
        rs=stat.executeQuery(sql);
        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) {
throw new DaoException(format("String_Node_Str",st.toString(),st.toPreparedStatement()),e);
}
}