public Map<String, List> fetchBibHolding(boolean cursor) throws SQLException {
    String holdingId = "";
    String tempHoldingId = "";
    List bibIds = new ArrayList();
    Map<String, List> map = null;

    if (cursor) {
      while (bibHoldingsResultSet.next()) {
        holdingId = "who-" + bibHoldingsResultSet.getString("HOLDINGS_ID");
        if (StringUtils.isNotEmpty(tempHoldingId) && !tempHoldingId.equals(holdingId)) {

          if (bibIds.size() > 0) {
            map = new HashMap<>();
            bibIds.remove(0);
            map.put(tempHoldingId, bibIds);
            return map;
          }
        }

        bibIds.add("wbm-" + bibHoldingsResultSet.getString("BIB_ID"));
        tempHoldingId = holdingId;
      }

    } else {
      while (bibHoldingsResultSet.next()) {
        holdingId = "who-" + bibHoldingsResultSet.getString("HOLDINGS_ID");
        if (StringUtils.isNotEmpty(tempHoldingId) && !tempHoldingId.equals(holdingId)) {

          map = new HashMap<>();
          map.put(tempHoldingId, bibIds);
          return map;
        }
        bibIds.add("wbm-" + bibHoldingsResultSet.getString("BIB_ID"));
        tempHoldingId = holdingId;
      }
    }

    if (bibIds.size() > 0) {
      map = new HashMap<>();
      bibIds.remove(0);
      map.put(tempHoldingId, bibIds);
      return map;
    } else {
      map = null;
    }
    bibHoldingsResultSet.close();
    return map;
  }
  /** Returns a connection to the database */
  public synchronized Connection get() throws DataException {
    // ensure we haven't used too many connections
    if (usedConnections.size() >= MAX_CONNECTIONS) {
      throw new DataException(
          "The database connection pool is out of connections -- a maximum number of "
              + MAX_CONNECTIONS);
    } // if

    try {
      // do we have enough connections to assign one out?
      if (freeConnections.size() == 0) {
        freeConnections.add(createConnection());
      }

      // return the first free connection
      Connection conn = freeConnections.remove(0);
      usedConnections.add(conn);
      // Logger.global.info("Gave out a connection from the pool.  Free size is now: " +
      // freeConnections.size() + "/" + (freeConnections.size() + usedConnections.size()));
      return conn;
    } catch (Exception e) {
      throw new DataException(
          "An error occurred while retrieving a database connection from the pool", e);
    }
  } // get
  /**
   * @param arg0
   * @roseuid 3F4E5F40012D
   */
  public void connectionErrorOccurred(ConnectionEvent event) {
    logger.debug("Connection Error " + event.getSQLException().getMessage());

    synchronized (connectionPool) {
      if (connectionPool.size() <= connectionPoolSize) {
        connectionPool.remove(event.getSource());
        if (!SHUTTING_DOWN) {
          try {
            installConnection();
          } catch (EmanagerDatabaseException e) {
            // noop.  can't throw an exception here, so we'll ignore.
            // It will surface later.
          }
        }
      }
    }
  }
  /** Releases a connection that was previously in use */
  public synchronized void release(Connection conn) throws DataException {
    try {
      // be sure that this connection was committed (so it is at a fresh, new transaction)
      conn.commit();

      // first remove the connection from the used list
      usedConnections.remove(conn);

      // next add it back to the free connection list
      freeConnections.add(conn);
      // Logger.global.info("Released a connection back to the pool.  Free size is now: " +
      // freeConnections.size() + "/" + (freeConnections.size() + usedConnections.size()));
    } catch (Exception e) {
      throw new DataException(
          "An error occurred while releasing a database connection back to the pool", e);
    }
  } // release
  public List<ReportParameter> getAvailableParameters(Report report) throws ProviderException {
    List<ReportParameter> parameters = getReportParameters();

    Iterator<ReportParameter> iterator = parameters.iterator();
    while (iterator.hasNext()) {
      ReportParameter rp = iterator.next();

      Iterator<ReportParameterMap> reportIterator = report.getParameters().iterator();
      while (reportIterator.hasNext()) {
        ReportParameterMap rpMap = reportIterator.next();

        if (rp.getId().equals(rpMap.getReportParameter().getId())) {
          parameters.remove(rp);
          iterator = parameters.iterator();
        }
      }
    }

    return parameters;
  }
  /**
   * @return Connection
   * @roseuid 3F3A5FFD0338
   */
  public Connection getConnection() throws EmanagerDatabaseException {
    long connectionId;
    Connection connection;
    PooledConnection pooledConnection;

    connection = null;
    pooledConnection = null;
    connectionId = InvalidConnectionId;

    try {
      synchronized (connectionPool) {
        if (!connectionPool.isEmpty()) {
          try {
            boolean connectionClosed;

            connectionClosed = false;

            pooledConnection = (PooledConnection) connectionPool.remove(0);
            connection = pooledConnection.getConnection();
            connection.clearWarnings();
            connectionId = getConnectionID(connection);
            connectionClosed = connection.isClosed();
            if (connectionId == InvalidConnectionId || connectionClosed == true) {
              logger.debug("Pooled connection closed.");
              connection = null;
            }
          } catch (SQLException sqe) {
            logger.debug("Pooled connection closed.");
            connection = null;
          }
        }
      }

      if (connection == null) {
        logger.debug("Getting a new connection.");
        pooledConnection = poolDataSource.getPooledConnection();
        pooledConnection.addConnectionEventListener(this);
        connection = pooledConnection.getConnection();
        connection.clearWarnings();
        connectionId = getConnectionID(connection);
      }
    } catch (SQLException sqe) {
      String logString;
      EmanagerDatabaseException ede;

      logString =
          EmanagerDatabaseStatusCode.UnableToGetPooledConnection.getStatusCodeDescription()
              + sqe.getMessage();

      logger.error(logString);
      ede =
          new EmanagerDatabaseException(
              EmanagerDatabaseStatusCode.UnableToGetPooledConnection, logString);
      throw ede;
    }

    if (connectionId == InvalidConnectionId) {
      EmanagerDatabaseException ede;
      ede =
          new EmanagerDatabaseException(
              EmanagerDatabaseStatusCode.UnableToGetPooledConnection,
              EmanagerDatabaseStatusCode.UnableToGetPooledConnection.getStatusCodeDescription());
      throw ede;
    }

    logger.debug(
        "\n*****************************"
            + "\nPooled Connection Init"
            + "\nCon ID:"
            + connectionId
            + "\nCon Object:"
            + pooledConnection
            + "\nPool Object:"
            + connection
            + "\n*****************************");

    return connection;
  }
  /**
   * 生产checkbox html代码
   *
   * @param chkName checkbox 名字
   * @param checkedValues 以,分隔
   * @param lineValues 一行显示多少个checkbox 0所有
   * @return
   */
  public static String getCheckHtml(
      String company_id, String chkName, List<String> lsChkValues, int lineValues) {
    int showValues = 0; // 已经显示checkbox 数量 断行后 重新计数
    int width = 110;
    String item_id = null;
    String item_name = null;
    StringBuffer buf = new StringBuffer(64);

    buf.append(
        "<table cellspacing='1' cellpadding='2' border='0' class='TblClass' style='width:100%'>\r\n");
    for (Item topItem : Item.getTopItems()) {
      showValues = 0;
      width = 110;
      if (topItem.getItem_state() == 0) continue;

      if (topItem.getItem_id().equals("3")) {
        // continue;
      }

      if (topItem.getItem_id().equals("4") && !company_id.equals("xt_qd")) continue;

      if (topItem.getItem_id().equals("5") && !company_id.equals("xt_kpl")) continue;

      if (topItem.getItem_id().equals("6") && !company_id.equals("xt_sz")) continue;

      if (topItem.getItem_code().equals("PERSONAL")) {
        if (company_id.equals("xiaen")) {
          topItem = Item.getItemByCode("PERSONAL.JF");
        } else {
          topItem = Item.getItemByCode("PERSONAL.CGKS");
        }
      }
      if (topItem.getItem_code().equals("PERSONAL.JF")
          || topItem.getItem_code().equals("PERSONAL.CGKS")
          || topItem.getItem_code().equals("PERSONAL")) {
        int rowIndex = 1;
        buf.append(
            "<tr height='25px'><td align=\"right\" class=\"DetailBar\" width=80 rowspan="
                + topItem.getChildren().size()
                + ">"
                + topItem.getItem_name()
                + "</td>\r\n");
        for (Item item1 : topItem.getChildren()) {
          if (item1.getItem_state() == 0) continue;

          if (rowIndex == 1) {
            buf.append("<td align='right' class='DetailBar'>" + item1.getItem_name() + "</td>\r\n");
          } else {
            buf.append(
                "<tr><td align='right' class='DetailBar'>" + item1.getItem_name() + "</td>\r\n");
          }

          java.util.List<Item> lsItem = item1.getChildren();
          buf.append("<td class='DetailBar' style='width:560px'>");

          for (Item item : lsItem) {
            boolean bChecked = false;
            if (item.getItem_state() == 0) continue;

            item_id = item.getItem_id();
            item_name = item.getItem_name();
            for (int idx = 0; lsChkValues != null && idx < lsChkValues.size(); idx++) {
              String val = lsChkValues.get(idx);
              if (val.equals(item_id)) {
                bChecked = true;
                lsChkValues.remove(idx);
                break;
              }
            }
            buf.append(
                "  <span style=\"width:"
                    + width
                    + "px\"><input type='checkbox' name='"
                    + chkName
                    + "' showName='"
                    + item_name
                    + "' value='"
                    + item_id
                    + "'");
            if (bChecked) buf.append(" checked");
            buf.append(">" + item_name + "</input></span>");
            showValues++;
            if (lineValues > 0 && showValues == lineValues) {
              buf.append("<br>");
              showValues = 0;
            }
          }
          buf.append("</td></tr>\r\n");
          rowIndex++;
        }

      } else {
        boolean has_child = false;
        java.util.List<Item> lsItem = topItem.getChildren();
        for (Item item : lsItem) {
          if (!topItem.getItem_id().equals("3")) {
            has_child = true;
            break;
          }
          if (JUtil.convertNull(item.getCompany_id()).length() > 0
              && item.getCompany_id().equals(company_id)) {
            has_child = true;
            break;
          }
        }

        if (has_child) {
          buf.append(
              "<tr><td align=\"right\" class=\"DetailBar\" width=80>"
                  + topItem.getItem_name()
                  + "</td>\r\n");
          buf.append("<td class=\"DetailBar\" colspan=2>");
          for (Item item : lsItem) {
            boolean bChecked = false;
            item_id = item.getItem_id();
            item_name = item.getItem_name();

            if (JUtil.convertNull(item.getCompany_id()).length() > 0
                && !item.getCompany_id().equals(company_id)) continue;
            for (int idx = 0; lsChkValues != null && idx < lsChkValues.size(); idx++) {
              String val = lsChkValues.get(idx);
              if (val.equals(item_id)) {
                bChecked = true;
                lsChkValues.remove(idx);
                break;
              }
            }
            buf.append(
                "  <span style=\"width:"
                    + width
                    + "px\"><input type='checkbox' name='"
                    + chkName
                    + "' value='"
                    + item_id
                    + "'");
            if (bChecked) buf.append(" checked");
            buf.append(">" + item_name + "</input></span>");
            showValues++;
            if (lineValues > 0 && showValues == lineValues) {
              buf.append("<br>");
              showValues = 0;
            }
          }
          buf.append("</td></tr>\r\n");
        }
      }
    }
    buf.append("</table>");
    /*
    for(int i=0; ls!=null&&i< ls.size(); i++)
    {
    	String szCourse = ls.get(i);
    	if( szCourse.length() ==0) continue;

    	buf.append("  <input type='checkbox' name='" + chkName + "' value='" + szCourse+ "'" );
    	buf.append(" checked>" + szCourse + "</input>");

    	showValues ++;
    	if( lineValues >0 && showValues  == lineValues){buf.append("<br>"); showValues =0;}
    }*/

    return buf.toString();
  }