com.mysql.cj.result

## Class Field

- java.lang.Object
- - com.mysql.cj.result.Field

All Implemented Interfaces:
  ProtocolEntity

    public class Field
    extends Object
    implements ProtocolEntity

Field is a class used to describe fields in a ResultSet

### Field Summary

Fields
`private int` `colDecimals`
`private short` `colFlag`
`private int` `collationIndex`
`private LazyString` `columnName`
`private LazyString` `databaseName`
`private String` `encoding`
`private String` `fullName`
`private long` `length`
`private MysqlType` `mysqlType`
`private int` `mysqlTypeId`
`private LazyString` `originalColumnName`
`private LazyString` `originalTableName`
`private LazyString` `tableName`

### Constructor Summary

Constructors
Constructor and Description
`Field(LazyString databaseName, LazyString tableName, LazyString originalTableName, LazyString columnName, LazyString originalColumnName, long length, int mysqlTypeId, short colFlag, int colDecimals, int collationIndex, String encoding, MysqlType mysqlType)`
`Field(String tableName, String columnName, int collationIndex, String encoding, MysqlType mysqlType, int length)` Used by prepared statements to re-use result set data conversion methods when generating bound parameter retrieval instance for statement interceptors.

### Method Summary

All Methods Instance Methods Concrete Methods
`private void` `adjustFlagsByMysqlType()`
`int` `getCollationIndex()`
`String` `getColumnLabel()`
`String` `getDatabaseName()`
`int` `getDecimals()`
`String` `getEncoding()` Returns the Java encoding for this field.
`short` `getFlags()`
`String` `getFullName()`
`int` `getJavaType()`
`long` `getLength()`
`MysqlType` `getMysqlType()`
`int` `getMysqlTypeId()`
`String` `getName()`
`String` `getOriginalName()`
`String` `getOriginalTableName()`
`String` `getTableName()`
`boolean` `getValueNeedsQuoting()`
`boolean` `isAutoIncrement()`
`boolean` `isBinary()`
`boolean` `isBlob()`
`boolean` `isFromFunction()`
`boolean` `isMultipleKey()`
`boolean` `isNotNull()`
`boolean` `isPrimaryKey()`
`boolean` `isReadOnly()` Is this field _definitely_ not writable?
`boolean` `isSingleBit()`
`boolean` `isUniqueKey()`
`boolean` `isUnsigned()`
`boolean` `isZeroFill()`
`void` `setBinary()`
`void` `setBlob()`
`void` `setFlags(short colFlag)`
`void` `setMysqlType(MysqlType mysqlType)`
`void` `setMysqlTypeId(int id)`
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### collationIndex

    private int collationIndex

#### encoding

    private String encoding

#### colDecimals

    private int colDecimals

#### colFlag

    private short colFlag

#### databaseName

    private LazyString databaseName

#### tableName

    private LazyString tableName

#### originalTableName

    private LazyString originalTableName

#### columnName

    private LazyString columnName

#### originalColumnName

    private LazyString originalColumnName

#### fullName

    private String fullName

#### length

    private long length

#### mysqlTypeId

    private int mysqlTypeId

#### mysqlType

    private MysqlType mysqlType

### Constructor Detail

#### Field

    public Field(LazyString databaseName,
                 LazyString tableName,
                 LazyString originalTableName,
                 LazyString columnName,
                 LazyString originalColumnName,
                 long length,
                 int mysqlTypeId,
                 short colFlag,
                 int colDecimals,
                 int collationIndex,
                 String encoding,
                 MysqlType mysqlType)

#### Field

    public Field(String tableName,
                 String columnName,
                 int collationIndex,
                 String encoding,
                 MysqlType mysqlType,
                 int length)

Used by prepared statements to re-use result set data conversion methods when generating bound parameter retrieval instance for statement interceptors.

Parameters:
  `tableName` - not used
  `columnName` - not used
  `collationIndex` - the MySQL collation/character set index
  `encoding` - encoding of data in this field
  `mysqlType` - `MysqlType`
  `length` - length in characters or bytes (for BINARY data).

### Method Detail

#### adjustFlagsByMysqlType

    private void adjustFlagsByMysqlType()

#### getEncoding

    public String getEncoding()

Returns the Java encoding for this field.

Returns:
  the Java encoding

#### getColumnLabel

    public String getColumnLabel()

#### getDatabaseName

    public String getDatabaseName()

#### getDecimals

    public int getDecimals()

#### getFullName

    public String getFullName()

#### getLength

    public long getLength()

#### getMysqlTypeId

    public int getMysqlTypeId()

#### setMysqlTypeId

    public void setMysqlTypeId(int id)

#### getName

    public String getName()

#### getOriginalName

    public String getOriginalName()

#### getOriginalTableName

    public String getOriginalTableName()

#### getJavaType

    public int getJavaType()

#### getTableName

    public String getTableName()

#### isAutoIncrement

    public boolean isAutoIncrement()

#### isBinary

    public boolean isBinary()

#### setBinary

    public void setBinary()

#### isBlob

    public boolean isBlob()

#### setBlob

    public void setBlob()

#### isMultipleKey

    public boolean isMultipleKey()

#### isNotNull

    public boolean isNotNull()

#### isPrimaryKey

    public boolean isPrimaryKey()

#### isFromFunction

    public boolean isFromFunction()

#### isReadOnly

    public boolean isReadOnly()

Is this field _definitely_ not writable?

Returns:
  true if this field can not be written to in an INSERT/UPDATE statement.

#### isUniqueKey

    public boolean isUniqueKey()

#### isUnsigned

    public boolean isUnsigned()

#### isZeroFill

    public boolean isZeroFill()

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### isSingleBit

    public boolean isSingleBit()

#### getValueNeedsQuoting

    public boolean getValueNeedsQuoting()

#### getCollationIndex

    public int getCollationIndex()

#### getMysqlType

    public MysqlType getMysqlType()

#### setMysqlType

    public void setMysqlType(MysqlType mysqlType)

#### getFlags

    public short getFlags()

#### setFlags

    public void setFlags(short colFlag)

Copyright © 2016, 2025, Oracle and/or its affiliates.