Convert parameter index to corresponding outputIndex.

@param parameterIndex index
@return index
@throws SQLException exception
187872
private int indexToOutputIndex(int parameterIndex) throws SQLException {
    try {
      if (outputParameterMapper[parameterIndex - 1] == -1) {
        //this is not an outputParameter
        throw new SQLException("Parameter in index '" + parameterIndex
            + "' is not declared as output parameter with method registerOutParameter");
      }
      return outputParameterMapper[parameterIndex - 1];
    } catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) {
      if (parameterIndex < 1) {
        throw new SQLException("Index " + parameterIndex + " must at minimum be 1");
      }
      throw new SQLException("Index value '" + parameterIndex
          + "' is incorrect. Maximum value is " + params.size());
    }
  }
923552
static public int extractIntResult(ResultSet rs, ResultSetMetaData rsmd, int index) throws Exception {

		int count = rsmd.getColumnCount();
		if( index > count || index < 1 ) {
			throw new Exception("Invalid index");
		}
		
		int type = rsmd.getColumnType(index);
		switch (type) {
			case java.sql.Types.INTEGER:
			case java.sql.Types.SMALLINT:
				return rs.getInt(index);
		}

		throw new Exception("Column type ("+type+") invalid for a string at index: "+index);
	}
406457
@Override
    public void setNString(int parameterIndex, String value) throws SQLException {
        internalStmt.setNString(parameterIndex, value);
    }
1069336
private int nameToIndex(String parameterName) throws SQLException {
    parameterMetadata.readMetadataFromDbIfRequired();
    for (int i = 1; i <= parameterMetadata.getParameterCount(); i++) {
      String name = parameterMetadata.getName(i);
      if (name != null && name.equalsIgnoreCase(parameterName)) {
        return i;
      }
    }
    throw new SQLException("there is no parameter with the name " + parameterName);
  }
549200
public String convertIndexToDisStr(int index)
    {
        int iErrorCode = this.moveToIndex(index);
        if (iErrorCode == DBConstants.NORMAL_RETURN)
        {
            if (displayFieldName != null)
                return m_record.getField(displayFieldName).getString();
            else
                return m_record.getField(m_iFieldSeq).getString();
        }
        else
            return Constants.BLANK;
    }
766777
public void setParameter(final int parameterIndex, final ParameterHolder holder)
      throws SQLException {
    if (parameterIndex >= 1 && parameterIndex < prepareResult.getParamCount() + 1) {
      parameters[parameterIndex - 1] = holder;
    } else {
      String error = "Could not set parameter at position " + parameterIndex
          + " (values was " + holder.toString() + ")\n"
          + "Query - conn:" + protocol.getServerThreadId()
          + "(" + (protocol.isMasterConnection() ? "M" : "S") + ") ";

      if (options.maxQuerySizeToLog > 0) {
        error += " - \"";
        if (sqlQuery.length() < options.maxQuerySizeToLog) {
          error += sqlQuery;
        } else {
          error += sqlQuery.substring(0, options.maxQuerySizeToLog) + "...";
        }
        error += "\"";
      } else {
        error += " - \"" + sqlQuery + "\"";
      }

      logger.error(error);
      throw ExceptionMapper.getSqlException(error);
    }
  }
519051
public List<T> handle(List<QueryParameters> outputList) throws MjdbcException {
        List<T> result = new ArrayList<T>();
        String parameterName = null;
        Object parameterValue = null;

        for (int i = 1; i < outputList.size(); i++) {
            if (this.columnName == null) {
                parameterName = outputList.get(i).getNameByPosition(this.columnIndex);
                parameterValue = outputList.get(i).getValue(parameterName);

                result.add((T) parameterValue);
            } else {
                parameterValue = outputList.get(i).getValue(this.columnName);

                result.add((T) parameterValue);
            }

        }

        return result;
    }
702063
protected int setInParameter(final PreparedStatement preparedStatement, final int index,
			final BindParameterMapperManager parameterMapperManager) throws SQLException {
		int parameterIndex = index;
		if (value instanceof List) {
			for (Object e : (List<?>) value) {
				setParameterObject(preparedStatement, parameterIndex, e, parameterMapperManager);

				parameterLog(parameterIndex);
				parameterIndex++;
			}
		} else {
			setParameterObject(preparedStatement, parameterIndex, value, parameterMapperManager);

			parameterLog(parameterIndex);
			parameterIndex++;
		}

		return parameterIndex;
	}
1001426
@Override
    public void setArray(int parameterIndex, Array x) throws SQLException {
        internalStmt.setArray(parameterIndex, x);
    }
153960
protected void checkIndex(int parameterIndex, int type, String getName) throws SQLException {
    checkIndex(parameterIndex);
    if (type != this.testReturn[parameterIndex - 1]) {
      throw new PSQLException(
          GT.tr("Parameter of type {0} was registered, but call to get{1} (sqltype={2}) was made.",
              "java.sql.Types=" + testReturn[parameterIndex - 1], getName,
                  "java.sql.Types=" + type),
          PSQLState.MOST_SPECIFIC_TYPE_DOES_NOT_MATCH);
    }
  }
1198133
final <t> ConvertibleType<t> param(final int index) {
        return this.params.length > index ? (ConvertibleType<t>)this.params[index] : null;
    }
448199
private static List<ArrayParameter> arrayParametersSortedAsc(Map<String, List<Integer>> parameterNamesToIndexes,
                                                                 Map<String, Query.ParameterSetter> parameters,
                                                                 boolean allowArrayParameters) {
        List<ArrayParameters.ArrayParameter> arrayParameters = new ArrayList<>();
        for(Map.Entry<String, Query.ParameterSetter> parameter : parameters.entrySet()) {
            if (parameter.getValue().parameterCount > 1) {
                if (!allowArrayParameters) {
                    throw new Sql2oException("Array parameters are not allowed in batch mode");
                }
                for(int i : parameterNamesToIndexes.get(parameter.getKey())) {
                    arrayParameters.add(new ArrayParameters.ArrayParameter(i, parameter.getValue().parameterCount));
                }
            }
        }
        Collections.sort(arrayParameters);

        return arrayParameters;
    }
1094290
private Parameter<?> getParameter(int index)
	{
		if (index < 0 || index >= listParams.size())
			return null;
		return listParams.get(index);
	}
1278440
@Override
	public SqlContext outParam(final String parameterName, final SQLType sqlType) {
		return param(new OutParameter(parameterName, sqlType));
	}
1339121
int findParameterIndex(String parameterName) throws SQLException {

        checkClosed();

        int index = parameterNameMap.get(parameterName, -1);

        if (index >= 0) {
            return index + 1;
        }

        throw Util.sqlException(ErrorCode.JDBC_COLUMN_NOT_FOUND,
                                parameterName);
    }
561728
Object getParameterAtIndex(int partitionIndex) {
        try {
            if (serializedParams != null) {
                return ParameterSet.getParameterAtIndex(partitionIndex, serializedParams.duplicate());
            } else {
                return params.get().getParam(partitionIndex);
            }
        }
        catch (Exception ex) {
            throw new RuntimeException("Invalid partitionIndex: " + partitionIndex, ex);
        }
    }
1120311
@Override
    public void setString(int parameterIndex, String x) throws SQLException {
        internalStmt.setString(parameterIndex, x);
    }