Java Code Examples for java.sql.JDBCType#VARCHAR

The following examples show how to use java.sql.JDBCType#VARCHAR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommonCachedRowSetTests.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
 
Example 2
Source File: CommonCachedRowSetTests.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
 
Example 3
Source File: CommonCachedRowSetTests.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
 
Example 4
Source File: CommonCachedRowSetTests.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
 
Example 5
Source File: CommonCachedRowSetTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
 
Example 6
Source File: CommonCachedRowSetTests.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
 
Example 7
Source File: CommonCachedRowSetTests.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
 
Example 8
Source File: CommonCachedRowSetTests.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
 
Example 9
Source File: DictInTermTypeMapper.java    From hsweb-framework with Apache License 2.0 6 votes vote down vote up
private boolean support(RDBColumnMetaData column) {
    if(column.getJdbcType()== JDBCType.VARCHAR){
        return false;
    }
    Class type = column.getJavaType();
    if (type != null && type.isArray()) {
        type = type.getComponentType();
    }

    return ((type != null && type.isEnum()
            && EnumDict.class.isAssignableFrom(type)
            && column.getJavaType().isArray())
            ||
            (column.getProperty(USE_DICT_MASK_FLAG).isTrue()
                    && column.getOptionConverter() != null));
}
 
Example 10
Source File: CommonCachedRowSetTests.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs, JDBCType.INTEGER},
        {rs, JDBCType.CHAR},
        {rs, JDBCType.VARCHAR},
        {rs, JDBCType.BIGINT},
        {rs, JDBCType.BOOLEAN},
        {rs, JDBCType.SMALLINT},
        {rs, JDBCType.DOUBLE},
        {rs, JDBCType.DECIMAL},
        {rs, JDBCType.REAL},
        {rs, JDBCType.TINYINT},
        {rs, JDBCType.DATE},
        {rs, JDBCType.TIME},
        {rs, JDBCType.TIMESTAMP},
        {rs, JDBCType.VARBINARY},
        {rs, JDBCType.ARRAY},
        {rs, JDBCType.REF},
        {rs, JDBCType.FLOAT}
    };
}
 
Example 11
Source File: BuilderUtilsTest.java    From das with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildParameters(){
    SqlBuilder builder = new SqlBuilder();
    Person.PersonDefinition p = Person.PERSON;
    builder.where(p.CityID.equal(1), AND, p.CountryID.greaterThan(2), OR, p.Name.like(null).nullable());
    List<Parameter> params =  builder.buildParameters();
    Parameter pr = new Parameter("h", JDBCType.VARCHAR, "A");
    pr.setValues(Arrays.asList("B", "C"));
    params.add(pr);

    Date date = new java.sql.Date(1L);
    Parameter pr2 = new Parameter("h", JDBCType.DATE, date);
    pr2.setValues(Arrays.asList(date,  date));
    params.add(pr2);

    List<DasParameter> ps = BuilderUtils.buildParameters(params);
    assertEquals(4, ps.size());
    assertEquals("h", ps.get(2).getName());//TODO

    List<Parameter> ps2 = BuilderUtils.fromParameters(ps);
    assertEquals(4, ps2.size());
    assertEquals("h", ps2.get(2).getName());
    assertEquals("A", ps2.get(2).getValue());
    assertEquals(Arrays.asList("B", "C"), ps2.get(2).getValues());

    assertEquals(date, ps2.get(3).getValue());
}
 
Example 12
Source File: DictTermTypeMapper.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
private boolean support(RDBColumnMetaData column) {
    if (column.getJdbcType() == JDBCType.VARCHAR) {
        return false;
    }
    Class type = column.getJavaType();
    if (type != null && type.isArray()) {
        type = type.getComponentType();
    }
    return ((type != null && type.isEnum()
            && EnumDict.class.isAssignableFrom(type)
            && column.getJavaType().isArray())
            ||
            (column.getProperty(USE_DICT_MASK_FLAG).isTrue() && column.getOptionConverter() != null));
}
 
Example 13
Source File: EasyOrmSqlBuilder.java    From hsweb-framework with Apache License 2.0 4 votes vote down vote up
private List<RDBColumnMetaData> createColumn(String prefix, String columnName, ResultMapping resultMapping) {
    List<RDBColumnMetaData> metaData = new ArrayList<>();
    if (resultMapping.getNestedQueryId() == null) {

        if (resultMapping.getNestedResultMapId() != null) {
            ResultMap nests = MybatisUtils.getResultMap(resultMapping.getNestedResultMapId());
            Set<ResultMapping> resultMappings = new HashSet<>(nests.getResultMappings());
            resultMappings.addAll(nests.getIdResultMappings());
            for (ResultMapping mapping : resultMappings) {
                metaData.addAll(createColumn(resultMapping.getProperty(),
                        org.springframework.util.StringUtils.hasText(resultMapping.getColumn())
                                ? resultMapping.getColumn()
                                : resultMapping.getProperty(),
                        mapping));
            }
            return metaData;
        }

        JDBCType jdbcType = JDBCType.VARCHAR;
        try {
            jdbcType = JDBCType.valueOf(resultMapping.getJdbcType().name());
        } catch (Exception e) {
            log.warn("can not parse jdbcType:{}", resultMapping.getJdbcType());
        }
        RDBColumnMetaData column = new RDBColumnMetaData();
        column.setJdbcType(jdbcType);
        column.setName(org.springframework.util.StringUtils.hasText(columnName)
                ? columnName.concat(".").concat(resultMapping.getColumn()) : resultMapping.getColumn());

        if (resultMapping.getTypeHandler() != null) {
            column.setProperty("typeHandler", resultMapping.getTypeHandler().getClass().getName());
        }
        if (!StringUtils.isNullOrEmpty(resultMapping.getProperty())) {
            column.setAlias(org.springframework.util.StringUtils.hasText(prefix)
                    ? prefix.concat(".").concat(resultMapping.getProperty()) : resultMapping.getProperty());

        }
        column.setJavaType(resultMapping.getJavaType());
        column.setProperty("resultMapping", resultMapping);
        metaData.add(column);
    }
    return metaData;
}
 
Example 14
Source File: SimpleDynamicFormService.java    From hsweb-framework with Apache License 2.0 4 votes vote down vote up
protected ValueConverter initColumnValueConvert(JDBCType jdbcType, Class javaType) {
    boolean isBasicClass = !classMapping
            .values()
            .contains(javaType) || javaType != Map.class || javaType != List.class;

    if (javaType.isEnum() && EnumDict.class.isAssignableFrom(javaType)) {
        return new EnumDictValueConverter<EnumDict>(() -> (List) Arrays.asList(javaType.getEnumConstants()));
    }
    switch (jdbcType) {
        case BLOB:
            if (!isBasicClass) {
                return new JSONValueConverter(javaType, new BlobValueConverter());
            }
            return new BlobValueConverter();
        case CLOB:
            if (!isBasicClass) {
                return new JSONValueConverter(javaType, new ClobValueConverter());
            }
            return new ClobValueConverter();
        case NUMERIC:
        case BIGINT:
        case INTEGER:
        case SMALLINT:
        case TINYINT:
            return new NumberValueConverter(javaType);
        case DATE:
        case TIMESTAMP:
        case TIME:
            return new DateTimeConverter("yyyy-MM-dd HH:mm:ss", javaType);
        default:
            if (!isBasicClass) {
                return new JSONValueConverter(javaType, new DefaultValueConverter());
            }
            if (javaType == String.class && (jdbcType == JDBCType.VARCHAR || jdbcType == JDBCType.NVARCHAR)) {
                return new DefaultValueConverter() {
                    @Override
                    public Object getData(Object value) {
                        if (value instanceof Number) {
                            return value.toString();
                        }
                        return super.getData(value);
                    }
                };
            }
            return new DefaultValueConverter();
    }

}