Class TypeMetadata

java.lang.Object
org.firebirdsql.jdbc.metadata.TypeMetadata

public class TypeMetadata extends Object
Helper class to determine type metadata conforming to expectations of DatabaseMetaData.
Since:
4.0
Author:
Mark Rotteveel
  • Method Details

    • getJdbcType

      public int getJdbcType()
      Returns:
      The Types or JaybirdTypeCodes code for this datatype
    • getSqlTypeName

      public String getSqlTypeName()
      Returns:
      The SQL datatype name, returns "NULL" if the type is unknown
    • getColumnSize

      public Integer getColumnSize()
      Returns the column size (precision) of the type.

      The value returned follows the definition used in DatabaseMetaData, as established in DatabaseMetaData.getColumns(String, String, String, String) for COLUMN_SIZE. The same definition is used for database metadata columns PRECISION in, among others, DatabaseMetaData.getFunctionColumns(String, String, String, String).

      This method will also return any non-zero precision information stored for other datatypes than those listed in the COLUMN_SIZE definition in the JDBC API.

      Returns:
      The column size as defined in DatabaseMetaData, or null.
    • getLength

      public Integer getLength()
      Returns:
      The field length in bytes
    • getScale

      public Integer getScale()
      Returns the scale of the field.

      For numerical types, returns a zero or positive scale. For types without scale, it returns null, for types that have a non-zero scale in the Firebird metadata, it returns the scale as stored.

      Returns:
      The scale of a field, or null.
    • getRadix

      public int getRadix()
      Returns:
      The radix of numerical precision (either 2 or 10; returns 10 for non-numerical, non-boolean types.
    • getCharOctetLength

      public Integer getCharOctetLength()
      Returns:
      The maximum number of bytes for a character type column, null otherwise
    • builder

      public static TypeMetadata.Builder builder(FirebirdSupportInfo supportInfo)
      Creates type metadata builder.
      Parameters:
      supportInfo - Firebird support info
      Returns:
      Builder for type metadata
    • getDataType

      public static int getDataType(int sqlType, int sqlSubType, int sqlScale, int characterSetId)
      Derives the JDBC data type from Types or JaybirdTypeCodes from metadata information.
      Parameters:
      sqlType - Firebird type code as used in the metadata tables
      sqlSubType - Firebird sub-type code as used in the metadata tables
      sqlScale - Firebird scale as used in the metadata tables
      characterSetId - Character set id as used in the metadata tables
      Returns:
      JDBC data type code.
    • getDataTypeName

      public static String getDataTypeName(int sqlType, int sqlSubType, int sqlScale)
      Derives the JDBC/SQL type name from metadata information.
      Parameters:
      sqlType - Firebird type code as used in the metadata tables
      sqlSubType - Firebird sub-type code as used in the metadata tables
      sqlScale - Firebird scale as used in the metadata tables
      Returns:
      JDBC/SQL type name