public Object readColumn()

in eventmesh-connectors/eventmesh-connector-canal/src/main/java/org/apache/eventmesh/connector/canal/sink/connector/CanalCheckConsumer.java [202:278]


    public Object readColumn(ResultSet rs, String colName, CanalMySQLType colType) throws Exception {
        switch (colType) {
            case TINYINT:
            case SMALLINT:
            case MEDIUMINT:
            case INT:
                Long valueLong = rs.getLong(colName);
                if (rs.wasNull()) {
                    return null;
                }
                if (valueLong.compareTo((long) Integer.MAX_VALUE) > 0) {
                    return valueLong;
                }
                return valueLong.intValue();
            case BIGINT:
                String v = rs.getString(colName);
                if (v == null) {
                    return null;
                }
                BigDecimal valueBigInt = new BigDecimal(v);
                if (valueBigInt.compareTo(BigDecimal.valueOf(Long.MAX_VALUE)) > 0) {
                    return valueBigInt;
                }
                return valueBigInt.longValue();
            case FLOAT:
            case DOUBLE:
            case DECIMAL:
                return rs.getBigDecimal(colName);
            case DATE:
                return rs.getObject(colName, LocalDate.class).toString();
            case TIME:
                return rs.getObject(colName, LocalTime.class).toString();
            case DATETIME:
            case TIMESTAMP:
                return rs.getObject(colName, LocalDateTime.class).toString();
            case YEAR:
                int year = rs.getInt(colName);
                if (rs.wasNull()) {
                    return null;
                }
                return year;
            case CHAR:
            case VARCHAR:
            case TINYTEXT:
            case TEXT:
            case MEDIUMTEXT:
            case LONGTEXT:
            case ENUM:
            case SET:
            case JSON:
                return rs.getString(colName);
            case BIT:
            case BINARY:
            case VARBINARY:
            case TINYBLOB:
            case BLOB:
            case MEDIUMBLOB:
            case LONGBLOB:
                return rs.getBytes(colName);
            case GEOMETRY:
            case GEOMETRY_COLLECTION:
            case GEOM_COLLECTION:
            case POINT:
            case LINESTRING:
            case POLYGON:
            case MULTIPOINT:
            case MULTILINESTRING:
            case MULTIPOLYGON:
                byte[] geo = rs.getBytes(colName);
                if (geo == null) {
                    return null;
                }
                return SqlUtils.toGeometry(geo);
            default:
                return rs.getObject(colName);
        }
    }