public T getObject()

in src/main/user-impl/java/com/mysql/cj/jdbc/result/ResultSetImpl.java [1271:1404]


    public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
        if (type == null) {
            throw SQLError.createSQLException("Type parameter can not be null", MysqlErrorNumbers.SQLSTATE_CONNJ_ILLEGAL_ARGUMENT, getExceptionInterceptor());
        }

        Lock connectionLock = checkClosed().getConnectionLock();
        connectionLock.lock();
        try {
            if (type.equals(String.class)) {
                return (T) getString(columnIndex);

            } else if (type.equals(BigDecimal.class)) {
                return (T) getBigDecimal(columnIndex);

            } else if (type.equals(BigInteger.class)) {
                return (T) getBigInteger(columnIndex);

            } else if (type.equals(Boolean.class) || type.equals(Boolean.TYPE)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, this.booleanValueFactory);

            } else if (type.equals(Byte.class) || type.equals(Byte.TYPE)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, this.byteValueFactory);

            } else if (type.equals(Short.class) || type.equals(Short.TYPE)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, this.shortValueFactory);

            } else if (type.equals(Integer.class) || type.equals(Integer.TYPE)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, this.integerValueFactory);

            } else if (type.equals(Long.class) || type.equals(Long.TYPE)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, this.longValueFactory);

            } else if (type.equals(Float.class) || type.equals(Float.TYPE)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, this.floatValueFactory);

            } else if (type.equals(Double.class) || type.equals(Double.TYPE)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, this.doubleValueFactory);

            } else if (type.equals(byte[].class)) {
                return (T) getBytes(columnIndex);

            } else if (type.equals(Date.class)) {
                return (T) getDate(columnIndex);

            } else if (type.equals(Time.class)) {
                return (T) getTime(columnIndex);

            } else if (type.equals(Timestamp.class)) {
                return (T) getTimestamp(columnIndex);

            } else if (type.equals(java.util.Date.class)) {
                Timestamp ts = getTimestamp(columnIndex);
                return ts == null ? null : (T) java.util.Date.from(ts.toInstant());

            } else if (type.equals(java.util.Calendar.class)) {
                return (T) getUtilCalendar(columnIndex);

            } else if (type.equals(Clob.class)) {
                return (T) getClob(columnIndex);

            } else if (type.equals(Blob.class)) {
                return (T) getBlob(columnIndex);

            } else if (type.equals(Array.class)) {
                return (T) getArray(columnIndex);

            } else if (type.equals(Ref.class)) {
                return (T) getRef(columnIndex);

            } else if (type.equals(URL.class)) {
                return (T) getURL(columnIndex);

            } else if (type.equals(Struct.class)) {
                throw new SQLFeatureNotSupportedException();

            } else if (type.equals(RowId.class)) {
                return (T) getRowId(columnIndex);

            } else if (type.equals(NClob.class)) {
                return (T) getNClob(columnIndex);

            } else if (type.equals(SQLXML.class)) {
                return (T) getSQLXML(columnIndex);

            } else if (type.equals(LocalDate.class)) {
                return (T) getLocalDate(columnIndex);

            } else if (type.equals(LocalDateTime.class)) {
                return (T) getLocalDateTime(columnIndex);

            } else if (type.equals(LocalTime.class)) {
                return (T) getLocalTime(columnIndex);

            } else if (type.equals(OffsetDateTime.class)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, this.defaultOffsetDateTimeValueFactory);

            } else if (type.equals(OffsetTime.class)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, this.defaultOffsetTimeValueFactory);

            } else if (type.equals(ZonedDateTime.class)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, this.defaultZonedDateTimeValueFactory);

            } else if (type.equals(Duration.class)) {
                checkRowPos();
                checkColumnBounds(columnIndex);
                return (T) this.thisRow.getValue(columnIndex - 1, new DurationValueFactory(this.session.getPropertySet()));
            }

            throw SQLError.createSQLException("Conversion not supported for type " + type.getName(), MysqlErrorNumbers.SQLSTATE_CONNJ_ILLEGAL_ARGUMENT,
                    getExceptionInterceptor());
        } finally {
            connectionLock.unlock();
        }
    }