Package org.firebirdsql.jdbc.metadata
Class TypeMetadata
java.lang.Object
org.firebirdsql.jdbc.metadata.TypeMetadata
Helper class to determine type metadata conforming to expectations of
DatabaseMetaData.- Since:
- 4.0
- Author:
- Mark Rotteveel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enum -
Method Summary
Modifier and TypeMethodDescriptionstatic TypeMetadata.Builderbuilder(FirebirdSupportInfo supportInfo) Creates type metadata builder.Returns the column size (precision) of the type.static intgetDataType(int sqlType, int sqlSubType, int sqlScale, int characterSetId) Derives the JDBC data type fromTypesorJaybirdTypeCodesfrom metadata information.static StringgetDataTypeName(int sqlType, int sqlSubType, int sqlScale) Derives the JDBC/SQL type name from metadata information.intintgetRadix()getScale()Returns the scale of the field.
-
Method Details
-
getJdbcType
public int getJdbcType()- Returns:
- The
TypesorJaybirdTypeCodescode for this datatype
-
getSqlTypeName
- Returns:
- The SQL datatype name, returns
"NULL"if the type is unknown
-
getColumnSize
Returns the column size (precision) of the type.The value returned follows the definition used in
DatabaseMetaData, as established inDatabaseMetaData.getColumns(String, String, String, String)forCOLUMN_SIZE. The same definition is used for database metadata columnsPRECISIONin, 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_SIZEdefinition in the JDBC API.- Returns:
- The column size as defined in
DatabaseMetaData, ornull.
-
getLength
- Returns:
- The field length in bytes
-
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
2or10; returns10for non-numerical, non-boolean types.
-
getCharOctetLength
- Returns:
- The maximum number of bytes for a character type column,
nullotherwise
-
builder
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 fromTypesorJaybirdTypeCodesfrom metadata information.- Parameters:
sqlType- Firebird type code as used in the metadata tablessqlSubType- Firebird sub-type code as used in the metadata tablessqlScale- Firebird scale as used in the metadata tablescharacterSetId- Character set id as used in the metadata tables- Returns:
- JDBC data type code.
-
getDataTypeName
Derives the JDBC/SQL type name from metadata information.- Parameters:
sqlType- Firebird type code as used in the metadata tablessqlSubType- Firebird sub-type code as used in the metadata tablessqlScale- Firebird scale as used in the metadata tables- Returns:
- JDBC/SQL type name
-