Top Fields Constructors Methods
com.mysql.cj

public final Enum MysqlType

extends Enum<MysqlType>
implements SQLType
Class Inheritance
All Implemented Interfaces
java.sql.SQLType
Imports
java.math.BigDecimal, .BigInteger, java.sql.Date, .SQLType, .Time, .Timestamp, .Types, java.time.LocalDateTime, com.mysql.cj.exceptions.FeatureNotAvailableException, com.mysql.cj.util.StringUtils

Field Summary

Modifier and TypeField and Description
public static final MysqlType
BIGINT

BIGINT[(M)] [UNSIGNED] [ZEROFILL] A large integer.

public static final MysqlType
BIGINT_UNSIGNED

BIGINT[(M)] UNSIGNED [ZEROFILL]

public static final MysqlType
BINARY

BINARY(M) The BINARY type is similar to the CHAR type, but stores binary byte strings rather than nonbinary character strings.

public static final MysqlType
BIT

BIT[(M)] A bit-field type.

public static final MysqlType
BLOB

BLOB[(M)] A BLOB column with a maximum length of 65,535 (216 - 1) bytes.

public static final MysqlType
BOOLEAN

BOOL, BOOLEAN These types are synonyms for TINYINT(1).

public static final MysqlType
CHAR

[NATIONAL] CHAR[(M)] [CHARACTER SET charset_name] [COLLATE collation_name] A fixed-length string that is always right-padded with spaces to the specified length when stored.

private final String
public static final MysqlType
DATE

DATE A date.

public static final MysqlType
DATETIME

DATETIME[(fsp)] A date and time combination.

public static final MysqlType
DECIMAL

DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL] A packed "exact" fixed-point number.

public static final MysqlType
DECIMAL_UNSIGNED

DECIMAL[(M[,D])] UNSIGNED [ZEROFILL]

public static final MysqlType
DOUBLE

DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL] A normal-size (double-precision) floating-point number.

public static final MysqlType
DOUBLE_UNSIGNED

DOUBLE[(M,D)] UNSIGNED [ZEROFILL]

public static final MysqlType
ENUM

ENUM('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name] An enumeration.

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
private final int
public static final MysqlType
FLOAT

FLOAT[(M,D)] [UNSIGNED] [ZEROFILL] A small (single-precision) floating-point number.

public static final MysqlType
FLOAT_UNSIGNED

FLOAT[(M,D)] UNSIGNED [ZEROFILL]

public static final MysqlType
GEOMETRY

Top class for Spatial Data Types Protocol: FIELD_TYPE_GEOMETRY = 255

public static final MysqlType
INT

INT[(M)] [UNSIGNED] [ZEROFILL] A normal-size integer.

public static final MysqlType
INT_UNSIGNED

INT[(M)] UNSIGNED [ZEROFILL]

private static final boolean
private static final boolean
private final boolean
protected final Class<?>
protected int
public static final MysqlType
JSON

The size of JSON documents stored in JSON columns is limited to the value of the max_allowed_packet system variable (max value 1073741824).

public static final MysqlType
LONGBLOB

LONGBLOB A BLOB column with a maximum length of 4,294,967,295 or 4GB (232 - 1) bytes.

public static final MysqlType
LONGTEXT

LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name] A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 - 1) characters.

public static final MysqlType
MEDIUMBLOB

MEDIUMBLOB A BLOB column with a maximum length of 16,777,215 (224 - 1) bytes.

public static final MysqlType
MEDIUMINT

MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL] A medium-sized integer.

public static final MysqlType
MEDIUMINT_UNSIGNED

MEDIUMINT[(M)] UNSIGNED [ZEROFILL]

public static final MysqlType
MEDIUMTEXT

MEDIUMTEXT [CHARACTER SET charset_name] [COLLATE collation_name] A TEXT column with a maximum length of 16,777,215 (224 - 1) characters.

private final String
public static final MysqlType
NULL

FIELD_TYPE_NULL = 6

private final Long
public static final MysqlType
SET

SET('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name] A set.

public static final MysqlType
SMALLINT

SMALLINT[(M)] [UNSIGNED] [ZEROFILL] A small integer.

public static final MysqlType
SMALLINT_UNSIGNED

SMALLINT[(M)] UNSIGNED [ZEROFILL]

public static final MysqlType
TEXT

TEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name] A TEXT column with a maximum length of 65,535 (216 - 1) characters.

public static final MysqlType
TIME

TIME[(fsp)] A time.

public static final MysqlType
TIMESTAMP

TIMESTAMP[(fsp)] A timestamp.

public static final MysqlType
TINYBLOB

TINYBLOB A BLOB column with a maximum length of 255 (28 - 1) bytes.

public static final MysqlType
TINYINT

TINYINT[(M)] [UNSIGNED] [ZEROFILL] A very small integer.

public static final MysqlType
TINYINT_UNSIGNED

TINYINT[(M)] UNSIGNED [ZEROFILL]

public static final MysqlType
TINYTEXT

TINYTEXT [CHARACTER SET charset_name] [COLLATE collation_name] A TEXT column with a maximum length of 255 (28 - 1) characters.

public static final MysqlType
UNKNOWN

Fall-back type for those MySQL data types which Connector/J cannot recognize.

public static final MysqlType
VARBINARY

VARBINARY(M) The VARBINARY type is similar to the VARCHAR type, but stores binary byte strings rather than nonbinary character strings.

public static final MysqlType
VARCHAR

[NATIONAL] VARCHAR(M) [CHARACTER SET charset_name] [COLLATE collation_name] A variable-length string.

public static final MysqlType
VECTOR

VECTOR[(M)] A VECTOR column with a maximum length of 65,532 (16383 x 4) bytes.

public static final MysqlType
YEAR

YEAR[(4)] A year in four-digit format.

Constructor Summary

AccessConstructor and Description
private
MysqlType(String
mysqlTypeName
mysqlTypeName
,
int
jdbcType
jdbcType
,
Class<?>
javaClass
javaClass
,
int
allowedFlags
allowedFlags
,
boolean
isDec
isDec
,
Long
represents the maximum column size that the server supports for the given datatype.
  • For numeric data, this is the maximum precision.
  • For character data, this is the length in characters.
  • For datetime datatypes, this is the length in characters of the String representation (assuming the maximum allowed precision of the fractional seconds component).
  • For binary data, this is the length in bytes.
  • For the ROWID datatype, this is the length in bytes.
  • Null is returned for data types where the column size is not applicable.
precision
,
String
params
createParams
)

Method Summary

Modifier and TypeMethod and Description
public static MysqlType
getByJdbcType(int jdbcType)

public static MysqlType

Returns:

MysqlType
getByName
(String
full MySQL type name
fullMysqlTypeName
)

Get MysqlType matching the full MySQL type name, for example "DECIMAL(5,3) UNSIGNED ZEROFILL".

public String
public String
public int
public String
getName()

Implements java.sql.SQLType.getName.

Returns the SQLType name that represents a SQL data type.

public Long

Returns:

precision
getPrecision
()

The PRECISION column represents the maximum column size that the server supports for the given datatype.

public String
getVendor()

Implements java.sql.SQLType.getVendor.

Returns the name of the vendor that supports this data type.

public Integer
getVendorTypeNumber()

Implements java.sql.SQLType.getVendorTypeNumber.

Returns the vendor specific type number for the data type.

public boolean
isAllowed(int flag)

public boolean

Returns:

true if the MySQL Type is a Decimal/Number Type
isDecimal
()

Checks if the MySQL Type is a Decimal/Number Type

public static boolean
public static boolean

Returns:

true if so
supportsConvert
(int
the type to convert from
fromType
,
int
the type to convert to
toType
)

Is CONVERT between the given SQL types supported?

public static MysqlType
public static MysqlType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BIGINTback to summary
public static final MysqlType BIGINT

BIGINT[(M)] [UNSIGNED] [ZEROFILL] A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615. Protocol: FIELD_TYPE_LONGLONG = 8 SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.

BIGINT_UNSIGNEDback to summary
public static final MysqlType BIGINT_UNSIGNED

BIGINT[(M)] UNSIGNED [ZEROFILL]

See Also
MysqlType#BIGINT
BINARYback to summary
public static final MysqlType BINARY

BINARY(M) The BINARY type is similar to the CHAR type, but stores binary byte strings rather than nonbinary character strings. M represents the column length in bytes. The CHAR BYTE data type is an alias for the BINARY data type. Protocol: no concrete type on the wire TODO: really?

BITback to summary
public static final MysqlType BIT

BIT[(M)] A bit-field type. M indicates the number of bits per value, from 1 to 64. The default is 1 if M is omitted. Protocol: FIELD_TYPE_BIT = 16

BLOBback to summary
public static final MysqlType BLOB

BLOB[(M)] A BLOB column with a maximum length of 65,535 (216 - 1) bytes. Each BLOB value is stored using a 2-byte length prefix that indicates the number of bytes in the value. An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest BLOB type large enough to hold values M bytes long. Protocol: FIELD_TYPE_BLOB = 252

BOOLEANback to summary
public static final MysqlType BOOLEAN

BOOL, BOOLEAN These types are synonyms for TINYINT(1). A value of zero is considered false. Nonzero values are considered true BOOLEAN is converted to TINYINT(1) during DDL execution i.e. it has the same precision=3. Thus we have to look at full data type name and convert TINYINT to BOOLEAN (or BIT) if it has "(1)" length specification. Protocol: FIELD_TYPE_TINY = 1

CHARback to summary
public static final MysqlType CHAR

[NATIONAL] CHAR[(M)] [CHARACTER SET charset_name] [COLLATE collation_name] A fixed-length string that is always right-padded with spaces to the specified length when stored. M represents the column length in characters. The range of M is 0 to 255. If M is omitted, the length is 1. Note Trailing spaces are removed when CHAR values are retrieved unless the PAD_CHAR_TO_FULL_LENGTH SQL mode is enabled. CHAR is shorthand for CHARACTER. NATIONAL CHAR (or its equivalent short form, NCHAR) is the standard SQL way to define that a CHAR column should use some predefined character set. MySQL 4.1 and up uses utf8 as this predefined character set. MySQL permits you to create a column of type CHAR(0). This is useful primarily when you have to be compliant with old applications that depend on the existence of a column but that do not actually use its value. CHAR(0) is also quite nice when you need a column that can take only two values: A column that is defined as CHAR(0) NULL occupies only one bit and can take only the values NULL and '' (the empty string). Protocol: FIELD_TYPE_STRING = 254

createParamsback to summary
private final String createParams
DATEback to summary
public static final MysqlType DATE

DATE A date. The supported range is '1000-01-01' to '9999-12-31'. MySQL displays DATE values in 'YYYY-MM-DD' format, but permits assignment of values to DATE columns using either strings or numbers. Protocol: FIELD_TYPE_DATE = 10

DATETIMEback to summary
public static final MysqlType DATETIME

DATETIME[(fsp)] A date and time combination. The supported range is '1000-01-01 00:00:00.000000' to '9999-12-31 23:59:59.999999'. MySQL displays DATETIME values in 'YYYY-MM-DD HH:MM:SS[.fraction]' format, but permits assignment of values to DATETIME columns using either strings or numbers. An optional fsp value in the range from 0 to 6 may be given to specify fractional seconds precision. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0. Protocol: FIELD_TYPE_DATETIME = 12

DECIMALback to summary
public static final MysqlType DECIMAL

DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL] A packed "exact" fixed-point number. M is the total number of digits (the precision) and D is the number of digits after the decimal point (the scale). The decimal point and (for negative numbers) the "-" sign are not counted in M. If D is 0, values have no decimal point or fractional part. The maximum number of digits (M) for DECIMAL is 65. The maximum number of supported decimals (D) is 30. If D is omitted, the default is 0. If M is omitted, the default is 10. Protocol: FIELD_TYPE_DECIMAL = 0 Protocol: FIELD_TYPE_NEWDECIMAL = 246 These types are synonyms for DECIMAL: DEC[(M[,D])] [UNSIGNED] [ZEROFILL], NUMERIC[(M[,D])] [UNSIGNED] [ZEROFILL], FIXED[(M[,D])] [UNSIGNED] [ZEROFILL]

DECIMAL_UNSIGNEDback to summary
public static final MysqlType DECIMAL_UNSIGNED

DECIMAL[(M[,D])] UNSIGNED [ZEROFILL]

See Also
MysqlType#DECIMAL
DOUBLEback to summary
public static final MysqlType DOUBLE

DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL] A normal-size (double-precision) floating-point number. Permissible values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308. These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system. M is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted, values are stored to the limits permitted by the hardware. A double-precision floating-point number is accurate to approximately 15 decimal places. Protocol: FIELD_TYPE_DOUBLE = 5 These types are synonyms for DOUBLE: DOUBLE PRECISION[(M,D)] [UNSIGNED] [ZEROFILL], REAL[(M,D)] [UNSIGNED] [ZEROFILL]. Exception: If the REAL_AS_FLOAT SQL mode is enabled, REAL is a synonym for FLOAT rather than DOUBLE.

DOUBLE_UNSIGNEDback to summary
public static final MysqlType DOUBLE_UNSIGNED

DOUBLE[(M,D)] UNSIGNED [ZEROFILL]

See Also
MysqlType#DOUBLE
ENUMback to summary
public static final MysqlType ENUM

ENUM('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name] An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special '' error value. ENUM values are represented internally as integers. An ENUM column can have a maximum of 65,535 distinct elements. (The practical limit is less than 3000.) A table can have no more than 255 unique element list definitions among its ENUM and SET columns considered as a group Protocol: FIELD_TYPE_ENUM = 247

FIELD_FLAG_AUTO_INCREMENTback to summary
public static final int FIELD_FLAG_AUTO_INCREMENT
FIELD_FLAG_BINARYback to summary
public static final int FIELD_FLAG_BINARY
FIELD_FLAG_BLOBback to summary
public static final int FIELD_FLAG_BLOB
FIELD_FLAG_MULTIPLE_KEYback to summary
public static final int FIELD_FLAG_MULTIPLE_KEY
FIELD_FLAG_NOT_NULLback to summary
public static final int FIELD_FLAG_NOT_NULL
FIELD_FLAG_PRIMARY_KEYback to summary
public static final int FIELD_FLAG_PRIMARY_KEY
FIELD_FLAG_UNIQUE_KEYback to summary
public static final int FIELD_FLAG_UNIQUE_KEY
FIELD_FLAG_UNSIGNEDback to summary
public static final int FIELD_FLAG_UNSIGNED
FIELD_FLAG_ZEROFILLback to summary
public static final int FIELD_FLAG_ZEROFILL
FIELD_TYPE_BITback to summary
public static final int FIELD_TYPE_BIT
FIELD_TYPE_BLOBback to summary
public static final int FIELD_TYPE_BLOB
FIELD_TYPE_DATEback to summary
public static final int FIELD_TYPE_DATE
FIELD_TYPE_DATETIMEback to summary
public static final int FIELD_TYPE_DATETIME
FIELD_TYPE_DECIMALback to summary
public static final int FIELD_TYPE_DECIMAL
FIELD_TYPE_DOUBLEback to summary
public static final int FIELD_TYPE_DOUBLE
FIELD_TYPE_ENUMback to summary
public static final int FIELD_TYPE_ENUM
FIELD_TYPE_FLOATback to summary
public static final int FIELD_TYPE_FLOAT
FIELD_TYPE_GEOMETRYback to summary
public static final int FIELD_TYPE_GEOMETRY
FIELD_TYPE_INT24back to summary
public static final int FIELD_TYPE_INT24
FIELD_TYPE_JSONback to summary
public static final int FIELD_TYPE_JSON
FIELD_TYPE_LONGback to summary
public static final int FIELD_TYPE_LONG
FIELD_TYPE_LONG_BLOBback to summary
public static final int FIELD_TYPE_LONG_BLOB
FIELD_TYPE_LONGLONGback to summary
public static final int FIELD_TYPE_LONGLONG
FIELD_TYPE_MEDIUM_BLOBback to summary
public static final int FIELD_TYPE_MEDIUM_BLOB
FIELD_TYPE_NEWDECIMALback to summary
public static final int FIELD_TYPE_NEWDECIMAL
FIELD_TYPE_NULLback to summary
public static final int FIELD_TYPE_NULL
FIELD_TYPE_SETback to summary
public static final int FIELD_TYPE_SET
FIELD_TYPE_SHORTback to summary
public static final int FIELD_TYPE_SHORT
FIELD_TYPE_STRINGback to summary
public static final int FIELD_TYPE_STRING
FIELD_TYPE_TIMEback to summary
public static final int FIELD_TYPE_TIME
FIELD_TYPE_TIMESTAMPback to summary
public static final int FIELD_TYPE_TIMESTAMP
FIELD_TYPE_TINYback to summary
public static final int FIELD_TYPE_TINY
FIELD_TYPE_TINY_BLOBback to summary
public static final int FIELD_TYPE_TINY_BLOB
FIELD_TYPE_VAR_STRINGback to summary
public static final int FIELD_TYPE_VAR_STRING
FIELD_TYPE_VARCHARback to summary
public static final int FIELD_TYPE_VARCHAR
FIELD_TYPE_VECTORback to summary
public static final int FIELD_TYPE_VECTOR
FIELD_TYPE_YEARback to summary
public static final int FIELD_TYPE_YEAR
flagsMaskback to summary
private final int flagsMask
FLOATback to summary
public static final MysqlType FLOAT

FLOAT[(M,D)] [UNSIGNED] [ZEROFILL] A small (single-precision) floating-point number. Permissible values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38. These are the theoretical limits, based on the IEEE standard. The actual range might be slightly smaller depending on your hardware or operating system. M is the total number of digits and D is the number of digits following the decimal point. If M and D are omitted, values are stored to the limits permitted by the hardware. A single-precision floating-point number is accurate to approximately 7 decimal places. Protocol: FIELD_TYPE_FLOAT = 4 Additionally: FLOAT(p) [UNSIGNED] [ZEROFILL] A floating-point number. p represents the precision in bits, but MySQL uses this value only to determine whether to use FLOAT or DOUBLE for the resulting data type. If p is from 0 to 24, the data type becomes FLOAT with no M or D values. If p is from 25 to 53, the data type becomes DOUBLE with no M or D values. The range of the resulting column is the same as for the single-precision FLOAT or double-precision DOUBLE data types.

FLOAT_UNSIGNEDback to summary
public static final MysqlType FLOAT_UNSIGNED

FLOAT[(M,D)] UNSIGNED [ZEROFILL]

See Also
MysqlType#FLOAT
GEOMETRYback to summary
public static final MysqlType GEOMETRY

Top class for Spatial Data Types Protocol: FIELD_TYPE_GEOMETRY = 255

INTback to summary
public static final MysqlType INT

INT[(M)] [UNSIGNED] [ZEROFILL] A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295. Protocol: FIELD_TYPE_LONG = 3 INTEGER[(M)] [UNSIGNED] [ZEROFILL] is a synonym for INT.

INT_UNSIGNEDback to summary
public static final MysqlType INT_UNSIGNED

INT[(M)] UNSIGNED [ZEROFILL]

See Also
MysqlType#INT
IS_DECIMALback to summary
private static final boolean IS_DECIMAL
IS_NOT_DECIMALback to summary
private static final boolean IS_NOT_DECIMAL
isDecimalback to summary
private final boolean isDecimal
javaClassback to summary
protected final Class<?> javaClass
jdbcTypeback to summary
protected int jdbcType
JSONback to summary
public static final MysqlType JSON

The size of JSON documents stored in JSON columns is limited to the value of the max_allowed_packet system variable (max value 1073741824). (While the server manipulates a JSON value internally in memory, it can be larger; the limit applies when the server stores it.) Protocol: FIELD_TYPE_BIT = 245

LONGBLOBback to summary
public static final MysqlType LONGBLOB

LONGBLOB A BLOB column with a maximum length of 4,294,967,295 or 4GB (232 - 1) bytes. The effective maximum length of LONGBLOB columns depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGBLOB value is stored using a 4-byte length prefix that indicates the number of bytes in the value. Protocol: FIELD_TYPE_LONG_BLOB = 251

LONGTEXTback to summary
public static final MysqlType LONGTEXT

LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name] A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 - 1) characters. The effective maximum length is less if the value contains multibyte characters. The effective maximum length of LONGTEXT columns also depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGTEXT value is stored using a 4-byte length prefix that indicates the number of bytes in the value. Protocol: FIELD_TYPE_LONG_BLOB = 251

MEDIUMBLOBback to summary
public static final MysqlType MEDIUMBLOB

MEDIUMBLOB A BLOB column with a maximum length of 16,777,215 (224 - 1) bytes. Each MEDIUMBLOB value is stored using a 3-byte length prefix that indicates the number of bytes in the value. Protocol: FIELD_TYPE_MEDIUM_BLOB = 250

MEDIUMINTback to summary
public static final MysqlType MEDIUMINT

MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL] A medium-sized integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215. Protocol: FIELD_TYPE_INT24 = 9

MEDIUMINT_UNSIGNEDback to summary
public static final MysqlType MEDIUMINT_UNSIGNED

MEDIUMINT[(M)] UNSIGNED [ZEROFILL]

See Also
MysqlType#MEDIUMINT
MEDIUMTEXTback to summary
public static final MysqlType MEDIUMTEXT

MEDIUMTEXT [CHARACTER SET charset_name] [COLLATE collation_name] A TEXT column with a maximum length of 16,777,215 (224 - 1) characters. The effective maximum length is less if the value contains multibyte characters. Each MEDIUMTEXT value is stored using a 3-byte length prefix that indicates the number of bytes in the value. Protocol: FIELD_TYPE_MEDIUM_BLOB = 250

nameback to summary
private final String name

Hides java.lang.Enum.name.

NULLback to summary
public static final MysqlType NULL

FIELD_TYPE_NULL = 6

precisionback to summary
private final Long precision
SETback to summary
public static final MysqlType SET

SET('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name] A set. A string object that can have zero or more values, each of which must be chosen from the list of values 'value1', 'value2', ... SET values are represented internally as integers. A SET column can have a maximum of 64 distinct members. A table can have no more than 255 unique element list definitions among its ENUM and SET columns considered as a group Protocol: FIELD_TYPE_SET = 248

SMALLINTback to summary
public static final MysqlType SMALLINT

SMALLINT[(M)] [UNSIGNED] [ZEROFILL] A small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535. Protocol: FIELD_TYPE_SHORT = 2

SMALLINT_UNSIGNEDback to summary
public static final MysqlType SMALLINT_UNSIGNED

SMALLINT[(M)] UNSIGNED [ZEROFILL]

See Also
MysqlType#SMALLINT
TEXTback to summary
public static final MysqlType TEXT

TEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name] A TEXT column with a maximum length of 65,535 (216 - 1) characters. The effective maximum length is less if the value contains multibyte characters. Each TEXT value is stored using a 2-byte length prefix that indicates the number of bytes in the value. An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest TEXT type large enough to hold values M characters long. Protocol: FIELD_TYPE_BLOB = 252

TIMEback to summary
public static final MysqlType TIME

TIME[(fsp)] A time. The range is '-838:59:59.000000' to '838:59:59.000000'. MySQL displays TIME values in 'HH:MM:SS[.fraction]' format, but permits assignment of values to TIME columns using either strings or numbers. An optional fsp value in the range from 0 to 6 may be given to specify fractional seconds precision. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0. Protocol: FIELD_TYPE_TIME = 11

TIMESTAMPback to summary
public static final MysqlType TIMESTAMP

TIMESTAMP[(fsp)] A timestamp. The range is '1970-01-01 00:00:01.000000' UTC to '2038-01-19 03:14:07.999999' UTC. TIMESTAMP values are stored as the number of seconds since the epoch ('1970-01-01 00:00:00' UTC). A TIMESTAMP cannot represent the value '1970-01-01 00:00:00' because that is equivalent to 0 seconds from the epoch and the value 0 is reserved for representing '0000-00-00 00:00:00', the "zero" TIMESTAMP value. An optional fsp value in the range from 0 to 6 may be given to specify fractional seconds precision. A value of 0 signifies that there is no fractional part. If omitted, the default precision is 0. Protocol: FIELD_TYPE_TIMESTAMP = 7

TINYBLOBback to summary
public static final MysqlType TINYBLOB

TINYBLOB A BLOB column with a maximum length of 255 (28 - 1) bytes. Each TINYBLOB value is stored using a 1-byte length prefix that indicates the number of bytes in the value. Protocol:FIELD_TYPE_TINY_BLOB = 249

TINYINTback to summary
public static final MysqlType TINYINT

TINYINT[(M)] [UNSIGNED] [ZEROFILL] A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255. Protocol: FIELD_TYPE_TINY = 1

TINYINT_UNSIGNEDback to summary
public static final MysqlType TINYINT_UNSIGNED

TINYINT[(M)] UNSIGNED [ZEROFILL]

See Also
MysqlType#TINYINT
TINYTEXTback to summary
public static final MysqlType TINYTEXT

TINYTEXT [CHARACTER SET charset_name] [COLLATE collation_name] A TEXT column with a maximum length of 255 (28 - 1) characters. The effective maximum length is less if the value contains multibyte characters. Each TINYTEXT value is stored using a 1-byte length prefix that indicates the number of bytes in the value. Protocol:FIELD_TYPE_TINY_BLOB = 249

UNKNOWNback to summary
public static final MysqlType UNKNOWN

Fall-back type for those MySQL data types which Connector/J cannot recognize. Handled the same as BLOB. Has no protocol ID.

VARBINARYback to summary
public static final MysqlType VARBINARY

VARBINARY(M) The VARBINARY type is similar to the VARCHAR type, but stores binary byte strings rather than nonbinary character strings. M represents the maximum column length in bytes. Protocol: FIELD_TYPE_VARCHAR = 15 Protocol: FIELD_TYPE_VAR_STRING = 253

VARCHARback to summary
public static final MysqlType VARCHAR

[NATIONAL] VARCHAR(M) [CHARACTER SET charset_name] [COLLATE collation_name] A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,535. The effective maximum length of a VARCHAR is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used. For example, utf8 characters can require up to three bytes per character, so a VARCHAR column that uses the utf8 character set can be declared to be a maximum of 21,844 characters. MySQL stores VARCHAR values as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A VARCHAR column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes. Note MySQL 5.7 follows the standard SQL specification, and does not remove trailing spaces from VARCHAR values. VARCHAR is shorthand for CHARACTER VARYING. NATIONAL VARCHAR is the standard SQL way to define that a VARCHAR column should use some predefined character set. MySQL 4.1 and up uses utf8 as this predefined character set. NVARCHAR is shorthand for NATIONAL VARCHAR. Protocol: FIELD_TYPE_VARCHAR = 15 Protocol: FIELD_TYPE_VAR_STRING = 253

VECTORback to summary
public static final MysqlType VECTOR

VECTOR[(M)] A VECTOR column with a maximum length of 65,532 (16383 x 4) bytes. An optional length M can be given for this type to indicate the maximum number of entries in a VECTOR. M cannot exceed 16383. Each entry is a 4 Byte (single-precision) floating-point value. Protocol: FIELD_TYPE_VECTOR = 242

YEARback to summary
public static final MysqlType YEAR

YEAR[(4)] A year in four-digit format. MySQL displays YEAR values in YYYY format, but permits assignment of values to YEAR columns using either strings or numbers. Values display as 1901 to 2155, and 0000. Protocol: FIELD_TYPE_YEAR = 13

Constructor Detail

MysqlTypeback to summary
private MysqlType(String mysqlTypeName, int jdbcType, Class<?> javaClass, int allowedFlags, boolean isDec, Long precision, String createParams)
Parameters
mysqlTypeName:String

mysqlTypeName

jdbcType:int

jdbcType

javaClass:Class<?>

javaClass

allowedFlags:int

allowedFlags

isDec:boolean

isDec

precision:Long

represents the maximum column size that the server supports for the given datatype.

  • For numeric data, this is the maximum precision.
  • For character data, this is the length in characters.
  • For datetime datatypes, this is the length in characters of the String representation (assuming the maximum allowed precision of the fractional seconds component).
  • For binary data, this is the length in bytes.
  • For the ROWID datatype, this is the length in bytes.
  • Null is returned for data types where the column size is not applicable.
createParams:String

params

Method Detail

getByJdbcTypeback to summary
public static MysqlType getByJdbcType(int jdbcType)
getByNameback to summary
public static MysqlType getByName(String fullMysqlTypeName)

Get MysqlType matching the full MySQL type name, for example "DECIMAL(5,3) UNSIGNED ZEROFILL". Distinct *_UNSIGNED type will be returned if "UNSIGNED" is present in fullMysqlTypeName.

Parameters
fullMysqlTypeName:String

full MySQL type name

Returns:MysqlType

MysqlType

getClassNameback to summary
public String getClassName()
getCreateParamsback to summary
public String getCreateParams()
getJdbcTypeback to summary
public int getJdbcType()
getNameback to summary
public String getName()

Implements java.sql.SQLType.getName.

Doc from java.sql.SQLType.getName.

Returns the SQLType name that represents a SQL data type.

Returns:String

The name of this SQLType.

Annotations
@Override
getPrecisionback to summary
public Long getPrecision()

The PRECISION column represents the maximum column size that the server supports for the given datatype.

  • For numeric data, this is the maximum precision.
  • For character data, this is the length in characters.
  • For datetime datatypes, this is the length in characters of the String representation (assuming the maximum allowed precision of the fractional seconds component).
  • For binary data, this is the length in bytes.
  • For the ROWID datatype, this is the length in bytes.
  • Null is returned for data types where the column size is not applicable.
Returns:Long

precision

getVendorback to summary
public String getVendor()

Implements java.sql.SQLType.getVendor.

Doc from java.sql.SQLType.getVendor.

Returns the name of the vendor that supports this data type. The value returned typically is the package name for this vendor.

Returns:String

The name of the vendor for this data type

Annotations
@Override
getVendorTypeNumberback to summary
public Integer getVendorTypeNumber()

Implements java.sql.SQLType.getVendorTypeNumber.

Doc from java.sql.SQLType.getVendorTypeNumber.

Returns the vendor specific type number for the data type.

Returns:Integer

An Integer representing the vendor specific data type

Annotations
@Override
isAllowedback to summary
public boolean isAllowed(int flag)
isDecimalback to summary
public boolean isDecimal()

Checks if the MySQL Type is a Decimal/Number Type

Returns:boolean

true if the MySQL Type is a Decimal/Number Type

isSignedback to summary
public static boolean isSigned(MysqlType type)
supportsConvertback to summary
public static boolean supportsConvert(int fromType, int toType)

Is CONVERT between the given SQL types supported?

Parameters
fromType:int

the type to convert from

toType:int

the type to convert to

Returns:boolean

true if so

See Also
Types
valueOfback to summary
public static MysqlType valueOf(String name)
valuesback to summary
public static MysqlType[] values()