Package com.clickhouse.jdbc

# Class JdbcTypeMapping

java.lang.Object
com.clickhouse.jdbc.JdbcTypeMapping

public class JdbcTypeMapping extends Object
This class defines mappings among `Types`, `JDBCType`, `ClickHouseDataType`, `ClickHouseColumn`, and `Class`. It does not impact serialization and deserialization, which is handled separately by `ClickHouseDataProcessor`.

## Constructor Summary

Constructors
Constructor
Description
`JdbcTypeMapping()`

## Method Summary

Modifier and Type
Method
Description
`static JdbcTypeMapping`
`getAnsiMapping()`
Gets ANSI type mapping.
`protected Class<?>`
`getCustomJavaClass(com.clickhouse.data.ClickHouseColumn column, Map<String,Class<?>> typeMap)`
Gets custom Java class for the given column.
`protected com.clickhouse.data.ClickHouseDataType`
`getDataType(int sqlType)`
Gets corresponding `ClickHouseDataType` of the given `Types`.
`static JdbcTypeMapping`
`getDefaultMapping()`
Gets default type mapping.
`protected int`
`getSqlType(Class<?> javaClass)`
Gets corresponding `Types` for the given Java class.
`com.clickhouse.data.ClickHouseColumn`
`toColumn(int sqlType, int scaleOrLength)`
Converts `Types` to ClickHouse column.
`com.clickhouse.data.ClickHouseColumn`
`toColumn(JDBCType jdbcType, int scaleOrLength)`
Converts `JDBCType` to ClickHouse column.
`Class<?>`
`toJavaClass(com.clickhouse.data.ClickHouseColumn column, Map<String,Class<?>> typeMap)`
Converts `ClickHouseColumn` to `Class`.
`String`
`toNativeType(com.clickhouse.data.ClickHouseColumn column)`
Converts `ClickHouseColumn` to native type.
`int`
`toSqlType(com.clickhouse.data.ClickHouseColumn column, Map<String,Class<?>> typeMap)`
Converts `ClickHouseColumn` to generic SQL type defined in JDBC.

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

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

## Constructor Details

### JdbcTypeMapping

public JdbcTypeMapping()

## Method Details

### getDefaultMapping

public static JdbcTypeMapping getDefaultMapping()
Gets default type mapping.

Returns:
  non-null type mapping

### getAnsiMapping

public static JdbcTypeMapping getAnsiMapping()
Gets ANSI type mapping.

Returns:
  non-null type mapping

### getCustomJavaClass

protected Class<?> getCustomJavaClass(com.clickhouse.data.ClickHouseColumn column, Map<String,Class<?>> typeMap)
Gets custom Java class for the given column.

Parameters:
  `column` - non-null column definition
  `typeMap` - column type to Java class map, could be null
Returns:
  custom Java class which may or may not be null

### getDataType

protected com.clickhouse.data.ClickHouseDataType getDataType(int sqlType)
Gets corresponding `ClickHouseDataType` of the given `Types`.

Parameters:
  `sqlType` - generic SQL types defined in JDBC
Returns:
  non-null ClickHouse data type

### getSqlType

protected int getSqlType(Class<?> javaClass)
Gets corresponding `Types` for the given Java class.

Parameters:
  `javaClass` - non-null Java class
Returns:
  generic SQL type defined in JDBC

### toColumn

public com.clickhouse.data.ClickHouseColumn toColumn(JDBCType jdbcType, int scaleOrLength)
Converts `JDBCType` to ClickHouse column.

Parameters:
  `jdbcType` - JDBC type
  `scaleOrLength` - scale or length
Returns:
  non-null ClickHouse column

### toColumn

public com.clickhouse.data.ClickHouseColumn toColumn(int sqlType, int scaleOrLength)
Converts `Types` to ClickHouse column.

Parameters:
  `sqlType` - generic SQL types defined in JDBC
  `scaleOrLength` - scale or length
Returns:
  non-null ClickHouse column

### toJavaClass

public Class<?> toJavaClass(com.clickhouse.data.ClickHouseColumn column, Map<String,Class<?>> typeMap)
Converts `ClickHouseColumn` to `Class`.

Parameters:
  `column` - non-null column definition
  `typeMap` - optional custom type mapping
Returns:
  non-null Java class

### toNativeType

public String toNativeType(com.clickhouse.data.ClickHouseColumn column)
Converts `ClickHouseColumn` to native type.

Parameters:
  `column` - non-null column definition
Returns:
  non-null native type

### toSqlType

public int toSqlType(com.clickhouse.data.ClickHouseColumn column, Map<String,Class<?>> typeMap)
Converts `ClickHouseColumn` to generic SQL type defined in JDBC.

Parameters:
  `column` - non-null column definition
  `typeMap` - optional custom mapping
Returns:
  generic SQL type defined in JDBC