/**
   * @param ps The {@link java.sql.PreparedStatement} which will do an insert into the Mysql
   *     database.
   * @param gpo The {@link GPOMutable} object whose values need to be set in the preparted
   *     statement.
   * @param qCounter The current index in the prepared statement
   * @param isKey TODO use this
   * @return The current index in the prepared statement.
   * @throws SQLException
   */
  private int setParams(PreparedStatement ps, GPOMutable gpo, int qCounter, boolean isKey)
      throws SQLException {
    FieldsDescriptor fd = gpo.getFieldDescriptor();

    Map<String, Type> fieldToType = fd.getFieldToType();
    List<String> fields = fd.getFieldList();

    for (int fieldCounter = 0; fieldCounter < fields.size(); fieldCounter++, qCounter++) {
      String fieldName = fields.get(fieldCounter);

      if (fieldName.equals(DimensionsDescriptor.DIMENSION_TIME_BUCKET)) {
        continue;
      }

      Type type = fieldToType.get(fieldName);

      switch (type) {
        case BOOLEAN:
          {
            ps.setByte(qCounter, (byte) (gpo.getFieldBool(fieldName) ? 1 : 0));
            break;
          }
        case BYTE:
          {
            ps.setByte(qCounter, gpo.getFieldByte(fieldName));
            break;
          }
        case CHAR:
          {
            ps.setString(qCounter, Character.toString(gpo.getFieldChar(fieldName)));
            break;
          }
        case STRING:
          {
            ps.setString(qCounter, gpo.getFieldString(fieldName));
            break;
          }
        case SHORT:
          {
            ps.setInt(qCounter, gpo.getFieldShort(fieldName));
            break;
          }
        case INTEGER:
          {
            ps.setInt(qCounter, gpo.getFieldInt(fieldName));
            break;
          }
        case LONG:
          {
            ps.setLong(qCounter, gpo.getFieldLong(fieldName));
            break;
          }
        case FLOAT:
          {
            ps.setFloat(qCounter, gpo.getFieldFloat(fieldName));
            break;
          }
        case DOUBLE:
          {
            ps.setDouble(qCounter, gpo.getFieldDouble(fieldName));
            break;
          }
        default:
          {
            throw new UnsupportedOperationException("The type: " + type + " is not supported.");
          }
      }
    }

    return qCounter;
  }