public static int getJDBCTypeFromClass ( @ Nonnull final Class < ? > aClass ) { ValueEnforcer . notNull ( aClass , "Class" ) ; if ( ! ClassHelper . isArrayClass ( aClass ) ) { // CHAR, VARCHAR or LONGVARCHAR if ( aClass . equals ( String . class ) ) return Types . VARCHAR ; if ( aClass . equals ( BigDecimal . class ) ) return Types . NUMERIC ; // BIT or BOOLEAN if ( aClass . equals ( Boolean . class ) || aClass . equals ( boolean . class ) ) return Types . BOOLEAN ; if ( aClass . equals ( Byte . class ) || aClass . equals ( byte . class ) ) return Types . TINYINT ; if ( aClass . equals ( Character . class ) || aClass . equals ( char . class ) ) return Types . CHAR ; if ( aClass . equals ( Double . class ) || aClass . equals ( double . class ) ) return Types . DOUBLE ; if ( aClass . equals ( Float . class ) || aClass . equals ( float . class ) ) return Types . REAL ; if ( aClass . equals ( Integer . class ) || aClass . equals ( int . class ) ) return Types . INTEGER ; if ( aClass . equals ( Long . class ) || aClass . equals ( long . class ) ) return Types . BIGINT ; if ( aClass . equals ( Short . class ) || aClass . equals ( short . class ) ) return Types . SMALLINT ; if ( aClass . equals ( java . sql . Date . class ) ) return Types . DATE ; if ( aClass . equals ( java . sql . Time . class ) ) return Types . TIME ; if ( aClass . equals ( java . sql . Timestamp . class ) ) return Types . TIMESTAMP ; if ( aClass . equals ( java . time . ZonedDateTime . class ) ) return Types . TIMESTAMP ; if ( aClass . equals ( java . time . OffsetDateTime . class ) ) return Types . TIMESTAMP ; if ( aClass . equals ( java . time . LocalDateTime . class ) ) return Types . TIMESTAMP ; if ( aClass . equals ( java . time . LocalDate . class ) ) return Types . DATE ; if ( aClass . equals ( java . time . LocalTime . class ) ) return Types . TIME ; } else { final Class < ? > aComponentType = aClass . getComponentType ( ) ; if ( aComponentType . equals ( byte . class ) ) return Types . VARBINARY ; } LOGGER . warn ( "Failed to resolve JDBC type from class " + aClass . getName ( ) ) ; return Types . JAVA_OBJECT ; }
Determine the JDBC type from the passed class .