## org.h2.value
Class DataType

    java.lang.Object
      org.h2.value.DataType

    public class DataType

extends java.lang.Object

This class contains meta data information about data types, and can convert between Java objects and Values.

Field Summary
`boolean` `autoIncrement` If this is an autoincrement type.
`boolean` `caseSensitive` If this data type is an autoincrement type.
`boolean` `decimal` If this is a numeric type.
`int` `defaultDisplaySize` The default display size.
`long` `defaultPrecision` The default precision.
`int` `defaultScale` The default scale.
`boolean` `hidden` If this data type should not be listed in the database meta data.
`java.lang.String` `jdbc` The Java class name.
`long` `maxPrecision` The maximum supported precision.
`int` `maxScale` The highest possible scale.
`int` `memory` The number of bytes required for an object.
`int` `minScale` The lowest possible scale.
`java.lang.String` `name` The data type name.
`java.lang.String` `params` The list of parameters used in the column definition.
`java.lang.String` `prefix` The prefix required for the SQL literal representation.
`int` `sqlType` The SQL type.
`int` `sqlTypePos` How closely the data type maps to the corresponding JDBC SQL type (low is best).
`java.lang.String` `suffix` The suffix required for the SQL literal representation.
`boolean` `supportsPrecision` If the precision parameter is supported.
`boolean` `supportsScale` If the scale parameter is supported.
`int` `type` The value type of this data type.
`static int` `TYPE_LONGNVARCHAR` This constant is used for JDK 1.5 compatibility and equal to java.sql.Types.LONGNVARCHAR
`static int` `TYPE_NCHAR` This constant is used for JDK 1.5 compatibility and equal to java.sql.Types.NCHAR
`static int` `TYPE_NCLOB` This constant is used for JDK 1.5 compatibility and equal to java.sql.Types.NCLOB
`static int` `TYPE_NVARCHAR` This constant is used for JDK 1.5 compatibility and equal to java.sql.Types.NVARCHAR
`static int` `TYPE_RESULT_SET` This constant is used to represent the type of a ResultSet.

Constructor Summary
`DataType()`

Method Summary
`static int` `convertSQLTypeToValueType(int sqlType)` Convert a SQL type to a value type.
`static java.lang.Object` `convertTo(SessionInterface session, JdbcConnection conn, Value v, java.lang.Class<?> paramClass)` Convert a value to the specified class.
`static Value` `convertToValue(SessionInterface session, java.lang.Object x, int type)` Convert a Java object to a value.
`static int` `convertTypeToSQLType(int type)` Convert a value type to a SQL type.
`static int` `getAddProofType(int type)` Get the data type that will not overflow when calling 'add' 2 billion times.
`static DataType` `getDataType(int type)` Get the data type object for the given value type.
`static java.lang.Object` `getDefaultForPrimitiveType(java.lang.Class<?> clazz)` Get the default value in the form of a Java object for the given Java class.
`static DataType` `getTypeByName(java.lang.String s)` Get a data type object from a type name.
`static java.lang.String` `getTypeClassName(int type)` Get the name of the Java class for the given value type.
`static int` `getTypeFromClass(java.lang.Class<?> x)` Get the value type for the given Java class.
`static java.util.ArrayList<DataType>` `getTypes()` Get the list of data types.
`static boolean` `isLargeObject(int type)` Check if the given value type is a large object (BLOB or CLOB).
`static boolean` `isStringType(int type)` Check if the given value type is a String (VARCHAR,...).
`static Value` `readValue(SessionInterface session, java.sql.ResultSet rs, int columnIndex, int type)` Read a value from the given result set.
`static boolean` `supportsAdd(int type)` Check if the given value type supports the add operation.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TYPE_RESULT_SET

    public static final int TYPE_RESULT_SET

  This constant is used to represent the type of a ResultSet. There is no equivalent java.sql.Types value, but Oracle uses it to represent a ResultSet (OracleTypes.CURSOR = -10).

  See Also:
    Constant Field Values

### TYPE_LONGNVARCHAR

    public static final int TYPE_LONGNVARCHAR

  This constant is used for JDK 1.5 compatibility and equal to java.sql.Types.LONGNVARCHAR

  See Also:
    Constant Field Values

### TYPE_NCHAR

    public static final int TYPE_NCHAR

  This constant is used for JDK 1.5 compatibility and equal to java.sql.Types.NCHAR

  See Also:
    Constant Field Values

### TYPE_NVARCHAR

    public static final int TYPE_NVARCHAR

  This constant is used for JDK 1.5 compatibility and equal to java.sql.Types.NVARCHAR

  See Also:
    Constant Field Values

### TYPE_NCLOB

    public static final int TYPE_NCLOB

  This constant is used for JDK 1.5 compatibility and equal to java.sql.Types.NCLOB

  See Also:
    Constant Field Values

### type

    public int type

  The value type of this data type.

### name

    public java.lang.String name

  The data type name.

### sqlType

    public int sqlType

  The SQL type.

### jdbc

    public java.lang.String jdbc

  The Java class name.

### sqlTypePos

    public int sqlTypePos

  How closely the data type maps to the corresponding JDBC SQL type (low is best).

### maxPrecision

    public long maxPrecision

  The maximum supported precision.

### minScale

    public int minScale

  The lowest possible scale.

### maxScale

    public int maxScale

  The highest possible scale.

### decimal

    public boolean decimal

  If this is a numeric type.

### prefix

    public java.lang.String prefix

  The prefix required for the SQL literal representation.

### suffix

    public java.lang.String suffix

  The suffix required for the SQL literal representation.

### params

    public java.lang.String params

  The list of parameters used in the column definition.

### autoIncrement

    public boolean autoIncrement

  If this is an autoincrement type.

### caseSensitive

    public boolean caseSensitive

  If this data type is an autoincrement type.

### supportsPrecision

    public boolean supportsPrecision

  If the precision parameter is supported.

### supportsScale

    public boolean supportsScale

  If the scale parameter is supported.

### defaultPrecision

    public long defaultPrecision

  The default precision.

### defaultScale

    public int defaultScale

  The default scale.

### defaultDisplaySize

    public int defaultDisplaySize

  The default display size.

### hidden

    public boolean hidden

  If this data type should not be listed in the database meta data.

### memory

    public int memory

  The number of bytes required for an object.

Constructor Detail

### DataType

    public DataType()

Method Detail

### getTypes

    public static java.util.ArrayList<DataType> getTypes()

  Get the list of data types.

  Returns:
    the list

### readValue

    public static Value readValue(SessionInterface session,
                                  java.sql.ResultSet rs,
                                  int columnIndex,
                                  int type)

  Read a value from the given result set.

  Parameters:
    `session` - the session
    `rs` - the result set
    `columnIndex` - the column index (1 based)
    `type` - the data type
  Returns:
    the value

### getTypeClassName

    public static java.lang.String getTypeClassName(int type)

  Get the name of the Java class for the given value type.

  Parameters:
    `type` - the value type
  Returns:
    the class name

### getDataType

    public static DataType getDataType(int type)

  Get the data type object for the given value type.

  Parameters:
    `type` - the value type
  Returns:
    the data type object

### convertTypeToSQLType

    public static int convertTypeToSQLType(int type)

  Convert a value type to a SQL type.

  Parameters:
    `type` - the value type
  Returns:
    the SQL type

### convertSQLTypeToValueType

    public static int convertSQLTypeToValueType(int sqlType)

  Convert a SQL type to a value type.

  Parameters:
    `sqlType` - the SQL type
  Returns:
    the value type

### getTypeFromClass

    public static int getTypeFromClass(java.lang.Class<?> x)

  Get the value type for the given Java class.

  Parameters:
    `x` - the Java class
  Returns:
    the value type

### convertToValue

    public static Value convertToValue(SessionInterface session,
                                       java.lang.Object x,
                                       int type)

  Convert a Java object to a value.

  Parameters:
    `session` - the session
    `x` - the value
    `type` - the value type
  Returns:
    the value

### getTypeByName

    public static DataType getTypeByName(java.lang.String s)

  Get a data type object from a type name.

  Parameters:
    `s` - the type name
  Returns:
    the data type object

### isLargeObject

    public static boolean isLargeObject(int type)

  Check if the given value type is a large object (BLOB or CLOB).

  Parameters:
    `type` - the value type
  Returns:
    true if the value type is a lob type

### isStringType

    public static boolean isStringType(int type)

  Check if the given value type is a String (VARCHAR,...).

  Parameters:
    `type` - the value type
  Returns:
    true if the value type is a String type

### supportsAdd

    public static boolean supportsAdd(int type)

  Check if the given value type supports the add operation.

  Parameters:
    `type` - the value type
  Returns:
    true if add is supported

### getAddProofType

    public static int getAddProofType(int type)

  Get the data type that will not overflow when calling 'add' 2 billion times.

  Parameters:
    `type` - the value type
  Returns:
    the data type that supports adding

### getDefaultForPrimitiveType

    public static java.lang.Object getDefaultForPrimitiveType(java.lang.Class<?> clazz)

  Get the default value in the form of a Java object for the given Java class.

  Parameters:
    `clazz` - the Java class
  Returns:
    the default object

### convertTo

    public static java.lang.Object convertTo(SessionInterface session,
                                             JdbcConnection conn,
                                             Value v,
                                             java.lang.Class<?> paramClass)

  Convert a value to the specified class.

  Parameters:
    `session` - the session
    `conn` - the database connection
    `v` - the value
    `paramClass` - the target class
  Returns:
    the converted object