微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java.sql.JDBCType的实例源码

项目:the-vigilantes    文件StatementsTest.java   
/**
 * Helper method for *Setobject* tests.
 * Insert data into the given PreparedStatement,or any of its subclasses,with the following structure:
 * 1 - `id` INT
 * 2 - `ot1` VARCHAR
 * 3 - `ot2` BLOB
 * 4 - `odt1` VARCHAR
 * 5 - `odt2` BLOB
 * 
 * @param pstmt
 * @return the row count of inserted records.
 * @throws Exception
 */
private int insertTestDataOffsetDTTypes(PreparedStatement pstmt) throws Exception {
    pstmt.setInt(1,1);
    pstmt.setobject(2,testOffsetTime,JDBCType.VARCHAR);
    pstmt.setobject(3,testOffsetTime);
    pstmt.setobject(4,testOffsetDateTime,JDBCType.VARCHAR);
    pstmt.setobject(5,testOffsetDateTime);
    assertEquals(1,pstmt.executeUpdate());

    if (pstmt instanceof CallableStatement) {
        CallableStatement cstmt = (CallableStatement) pstmt;

        cstmt.setInt("id",2);
        cstmt.setobject("ot1",JDBCType.VARCHAR);
        cstmt.setobject("ot2",testOffsetTime);
        cstmt.setobject("odt1",JDBCType.VARCHAR);
        cstmt.setobject("odt2",testOffsetDateTime);
        assertEquals(1,cstmt.executeUpdate());

        return 2;
    }

    return 1;
}
项目:syndesis    文件DatabaseMetaDataHelper.java   
static List<sqlParam> getJDBCInfoByColumnNames(final DatabaseMetaData Meta,String catalog,String schema,String tableName,final List<sqlParam> params) throws sqlException {
    List<sqlParam> paramList = new ArrayList<>();
    for (int i=0; i<params.size(); i++) {
        sqlParam param = params.get(i);
        String columnName = param.getColumn();
        ResultSet column = Meta.getColumns(catalog,schema,tableName,columnName);
        if (column.getFetchSize() == 0) {
            //Postgresql does lowercase instead,so let's try that if we don't have a match
            column = Meta.getColumns(catalog,tableName.toLowerCase(),columnName.toLowerCase());
        }
        column.next();
        param.setJdbcType(JDBCType.valueOf(column.getInt("DATA_TYPE")));
        paramList.add(param);
    }
    return paramList;
}
项目:OpenVertretung    文件StatementsTest.java   
/**
 * Helper method for *Setobject* tests.
 * Insert data into the given PreparedStatement,cstmt.executeUpdate());

        return 2;
    }

    return 1;
}
项目:ProyectoPacientes    文件StatementsTest.java   
/**
 * Helper method for *Setobject* tests.
 * Insert data into the given PreparedStatement,cstmt.executeUpdate());

        return 2;
    }

    return 1;
}
项目:uroborosql    文件Parameter.java   
/**
 * {@link java.sql.Types} の値を {@link java.sql.sqlType} に変換する
 * @param sqlType {@link java.sql.Types} の値
 * @return {@link java.sql.sqlType} の値
 */
private sqlType tosqlType(final int sqlType) {
    for (JDBCType type : JDBCType.values()) {
        if (type.getvendorTypeNumber().intValue() == sqlType) {
            return type;
        }
    }
    //下位互換のため、念のため生成して返す
    return new sqlType() {
        @Override
        public Integer getvendorTypeNumber() {
            return sqlType;
        }

        @Override
        public String getvendor() {
            return "unkNown";
        }

        @Override
        public String getName() {
            return "unkNown name:" + sqlType;
        }
    };
}
项目:uroborosql    文件StreamParameter.java   
/**
 * ステートメントにストリームパラメータを登録。
 *
 * @param preparedStatement ステートメント
 * @param index パラメータインデックス
 * @param parameterMapperManager パラメータ変換管理クラス
 * @return 次のパラメータインデックス
 * @throws sqlException sql例外
 */
protected int setStreamParameter(final PreparedStatement preparedStatement,int index,final BindParameterMapperManager parameterMapperManager) throws sqlException {

    if (Objects.equals(sqlType,JDBCType.BLOB)) {
        if (len > -1) {
            preparedStatement.setBinaryStream(index,stream,len);
        } else {
            preparedStatement.setBinaryStream(index,stream);
        }
    } else if (Objects.equals(sqlType,JDBCType.CLOB)) {
        if (len > -1) {
            preparedStatement.setAsciiStream(index,len);
        } else {
            preparedStatement.setAsciiStream(index,stream);
        }
    } else {
        return super.setParameter(preparedStatement,index,parameterMapperManager);
    }

    parameterLog(index);
    index++;

    return index;
}
项目:uroborosql    文件sqlAgentTest.java   
/**
 * DB更新処理のテストケース。
 */
@Test
public void testExecuteUpdate() throws Exception {
    // 事前条件
    cleanInsert(Paths.get("src/test/resources/data/setup","testExecuteUpdate.ltsv"));

    sqlContext ctx = agent.contextFrom("example/selectinsert_product")
            .param("product_id",new BigDecimal("0"),JDBCType.DECIMAL)
            .param("jan_code","1234567890123",Types.CHAR);

    int updateCount = agent.update(ctx);
    assertEquals("データの登録に失敗しました。",1,updateCount);

    // 検証処理
    List<Map<String,Object>> expectedDataList = getDataFromFile(Paths.get(
            "src/test/resources/data/expected/sqlAgent","testExecuteUpdate.ltsv"));
    List<Map<String,Object>> actualDataList = agent.query("example/select_product")
            .paramList("product_id",1).stream(new MapResultSetConverter(CaseFormat.LOWER_SNAKE_CASE))
            .collect(Collectors.toList());

    assertEquals(expectedDataList.toString(),actualDataList.toString());
}
项目:uroborosql    文件sqlAgentTest.java   
/**
 * DB更新処理のテストケース。(Fluent API)
 */
@Test
public void testUpdateFluent() throws Exception {
    // 事前条件
    cleanInsert(Paths.get("src/test/resources/data/setup","testExecuteUpdate.ltsv"));

    int updateCount = agent.update("example/selectinsert_product")
            .param("product_id",Types.CHAR).count();
    assertEquals("データの登録に失敗しました。",actualDataList.toString());
}
项目:uroborosql    文件DebugsqlFilterTest.java   
@Test
public void testExecuteUpdatefilter() throws Exception {
    cleanInsert(Paths.get("src/test/resources/data/setup","testExecuteUpdate.ltsv"));
    List<String> log = TestAppender.getLogbackLogs(() -> {
        sqlContext ctx = agent.contextFrom("example/selectinsert_product").setsqlId("222")
                .param("_userName","testUserName").param("_funcId","testFunction")
                .param("product_id",JDBCType.DECIMAL)
                .param("jan_code",Types.CHAR);
        agent.update(ctx);
    });

    assertthat(log,is(Files.readAllLines(
                    Paths.get("src/test/resources/data/expected/DebugsqlFilter","testExecuteUpdatefilter.txt"),StandardCharsets.UTF_8)));
}
项目:BibliotecaPS    文件StatementsTest.java   
/**
 * Helper method for *Setobject* tests.
 * Insert data into the given PreparedStatement,cstmt.executeUpdate());

        return 2;
    }

    return 1;
}
项目:jdk8u-jdk    文件CommonCachedRowSetTests.java   
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs,JDBCType.INTEGER},{rs,JDBCType.CHAR},JDBCType.VARCHAR},JDBCType.BIGINT},JDBCType.BOOLEAN},JDBCType.SMALLINT},JDBCType.DOUBLE},JDBCType.DECIMAL},JDBCType.REAL},JDBCType.tinyint},JDBCType.DATE},JDBCType.TIME},JDBCType.TIMESTAMP},JDBCType.VARBINARY},JDBCType.ARRAY},JDBCType.REF},JDBCType.FLOAT}
    };
}
项目:jdk8u-jdk    文件CommonCachedRowSetTests.java   
private void compareRowSets(CachedRowSet crs,CachedRowSet crs1) throws Exception {

        int rows = crs.size();
        assertTrue(rows == crs1.size());

        ResultSetMetaData rsmd = crs.getMetaData();

        compareMetaData(rsmd,crs1.getMetaData());
        int cols = rsmd.getColumnCount();

        for (int row = 1; row <= rows; row++) {
            crs.absolute((row));
            crs1.absolute(row);
            for (int col = 1; col <= cols; coL++) {
                compareColumnValue(JDBCType.valueOf(rsmd.getColumnType(col)),crs,crs1,col);
            }
        }

    }
项目:openjdk-jdk10    文件CommonCachedRowSetTests.java   
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs,JDBCType.FLOAT}
    };
}
项目:openjdk-jdk10    文件CommonCachedRowSetTests.java   
private void compareRowSets(CachedRowSet crs,col);
            }
        }

    }
项目:openjdk9    文件CommonCachedRowSetTests.java   
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs,JDBCType.FLOAT}
    };
}
项目:openjdk9    文件CommonCachedRowSetTests.java   
private void compareRowSets(CachedRowSet crs,col);
            }
        }

    }
项目:dw-jdbc    文件CallableStatementTest.java   
@Test
public void testNull() throws Exception {
    DataWorldCallableStatement statement = sampleSparqlCallableStatement();
    statement.setString("p","not-null");
    statement.setBigDecimal("bigdecimal",null);
    statement.setDate("date",null);
    statement.setNString("nstring",null);
    statement.setNull("null",Types.VARCHAR);
    statement.setNull("null2",Types.VARCHAR,"IGnorED");
    statement.setobject("object",null);
    statement.setobject("object",null,Types.INTEGER);
    statement.setobject("object",JDBCType.INTEGER);
    statement.setString("string",null);
    statement.setTime("time",null);
    statement.setTimestamp("timestamp",null);
    statement.setURL("url",null);
    statement.execute();
    verify(lastBackendRequest).handle(Method.POST,sparql.urlPath(),Utils.TYPE_FORM_URLENCODED,String.join("&",Utils.queryParam("query","select ?s ?p ?o where {?s ?p ?o.} limit 10"),Utils.queryParam("$p","\"not-null\"")));
}
项目:dw-jdbc    文件PreparedStatementTest.java   
@Test
public void testNull() throws Exception {
    DataWorldPreparedStatement statement = sql.prepareStatement(sql.connect(),"select * from Fielding where yearid in (?,?,?)");
    int index = 0;
    statement.setString(++index,"not-null");
    statement.setBigDecimal(++index,null);
    statement.setDate(++index,null);
    statement.setNString(++index,null);
    statement.setNull(++index,Types.VARCHAR);
    statement.setNull(++index,"IGnorED");
    statement.setobject(++index,null);
    statement.setobject(++index,Types.INTEGER);
    statement.setobject(++index,JDBCType.INTEGER);
    statement.setString(++index,null);
    statement.setTime(++index,null);
    statement.setTimestamp(++index,null);
    statement.setURL(++index,sql.urlPath(),?)"),Utils.queryParam("$data_world_param0","\"not-null\"")));
}
项目:jdk8u_jdk    文件CommonCachedRowSetTests.java   
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs,JDBCType.FLOAT}
    };
}
项目:jdk8u_jdk    文件CommonCachedRowSetTests.java   
private void compareRowSets(CachedRowSet crs,col);
            }
        }

    }
项目:lookaside_java-1.8.0-openjdk    文件CommonCachedRowSetTests.java   
@DataProvider(name = "rowsetUsingDataTypes")
protected Object[][] rowsetUsingDataTypes() throws Exception {

    CachedRowSet rs = createDataTypesRowSet();
    return new Object[][]{
        {rs,JDBCType.FLOAT}
    };
}
项目:lookaside_java-1.8.0-openjdk    文件CommonCachedRowSetTests.java   
private void compareRowSets(CachedRowSet crs,col);
            }
        }

    }
项目:mybatis-dynamic-sql    文件CriterionRendererTest.java   
@Test
public void testAliasWithIgnore() {
    sqlTable table = sqlTable.of("foo");
    sqlColumn<Integer> column = table.column("id",JDBCType.INTEGER);

    IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
    sqlCriterion<Integer> criterion = sqlCriterion.withColumn(column)
            .withCondition(condition)
            .build();
    AtomicInteger sequence = new AtomicInteger(1);
    FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
            .withSequence(sequence)
            .withRenderingStrategy(RenderingStrategy.MYBATIS3)
            .withTableAliasCalculator(TableAliasCalculator.empty())
            .build()
            .render();

    SoftAssertions.assertSoftly(softly -> {
        softly.assertthat(fp.fragment()).isEqualTo("id = #{parameters.p1,jdbcType=INTEGER}");
        softly.assertthat(fp.parameters().size()).isEqualTo(1);
    });
}
项目:mybatis-dynamic-sql    文件CriterionRendererTest.java   
@Test
public void testAliasWithoutIgnore() {
    sqlTable table = sqlTable.of("foo");
    sqlColumn<Integer> column = table.column("id",JDBCType.INTEGER);
    IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
    sqlCriterion<Integer> criterion = sqlCriterion.withColumn(column)
            .withCondition(condition)
            .build();
    AtomicInteger sequence = new AtomicInteger(1);
    Map<sqlTable,String> tableAliases = new HashMap<>();
    tableAliases.put(table,"a");
    FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
            .withSequence(sequence)
            .withRenderingStrategy(RenderingStrategy.MYBATIS3)
            .withTableAliasCalculator(TableAliasCalculator.of(tableAliases))
            .build()
            .render();

    SoftAssertions.assertSoftly(softly -> {
        softly.assertthat(fp.fragment()).isEqualTo("a.id = #{parameters.p1,jdbcType=INTEGER}");
        softly.assertthat(fp.parameters().size()).isEqualTo(1);
    });
}
项目:mybatis-dynamic-sql    文件CriterionRendererTest.java   
@Test
public void testNoAliasWithIgnore() {
    sqlTable table = sqlTable.of("foo");
    sqlColumn<Integer> column = table.column("id",JDBCType.INTEGER);
    IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
    sqlCriterion<Integer> criterion = sqlCriterion.withColumn(column)
            .withCondition(condition)
            .build();
    AtomicInteger sequence = new AtomicInteger(1);
    FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
            .withSequence(sequence)
            .withRenderingStrategy(RenderingStrategy.MYBATIS3)
            .withTableAliasCalculator(TableAliasCalculator.empty())
            .build()
            .render();

    SoftAssertions.assertSoftly(softly -> {
        softly.assertthat(fp.fragment()).isEqualTo("id = #{parameters.p1,jdbcType=INTEGER}");
        softly.assertthat(fp.parameters().size()).isEqualTo(1);
    });
}
项目:mybatis-dynamic-sql    文件CriterionRendererTest.java   
@Test
public void testNoAliasWithoutIgnore() {
    sqlTable table = sqlTable.of("foo");
    sqlColumn<Integer> column = table.column("id",jdbcType=INTEGER}");
        softly.assertthat(fp.parameters().size()).isEqualTo(1);
    });
}
项目:mybatis-dynamic-sql    文件CriterionRendererTest.java   
@Test
public void testTypeHandler() {
    sqlTable table = sqlTable.of("foo");
    sqlColumn<Date> column = sqlColumn.withName("id")
            .withTable(table)
            .withJdbcType(JDBCType.DATE)
            .withTypeHandler("foo.Bar")
            .build();
    IsEqualTo<Date> condition = IsEqualTo.of(() -> new Date());
    sqlCriterion<Date> criterion = sqlCriterion.withColumn(column)
            .withCondition(condition)
            .build();
    AtomicInteger sequence = new AtomicInteger(1);
    FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
            .withSequence(sequence)
            .withRenderingStrategy(RenderingStrategy.MYBATIS3)
            .withTableAliasCalculator(TableAliasCalculator.empty())
            .build()
            .render();

    SoftAssertions.assertSoftly(softly -> {
        softly.assertthat(fp.fragment()).isEqualTo("id = #{parameters.p1,jdbcType=DATE,typeHandler=foo.Bar}");
        softly.assertthat(fp.parameters().size()).isEqualTo(1);
    });
}
项目:mybatis-dynamic-sql    文件CriterionRendererTest.java   
@Test
public void testTypeHandlerAndalias() {
    sqlTable table = sqlTable.of("foo");
    sqlColumn<Integer> column = table.column("id",JDBCType.INTEGER,"foo.Bar");
    IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
    sqlCriterion<Integer> criterion = sqlCriterion.withColumn(column)
            .withCondition(condition)
            .build();
    AtomicInteger sequence = new AtomicInteger(1);
    Map<sqlTable,"a");

    FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
            .withSequence(sequence)
            .withRenderingStrategy(RenderingStrategy.MYBATIS3)
            .withTableAliasCalculator(TableAliasCalculator.of(tableAliases))
            .build()
            .render();

    SoftAssertions.assertSoftly(softly -> {
        softly.assertthat(fp.fragment()).isEqualTo("a.id = #{parameters.p1,jdbcType=INTEGER,typeHandler=foo.Bar}");
        softly.assertthat(fp.parameters().size()).isEqualTo(1);
    });
}
项目:mybatis-dynamic-sql    文件CriterionRendererTest.java   
@Test
public void testAliasWithIgnore() {
    sqlTable table = sqlTable.of("foo");
    sqlColumn<Integer> column = table.column("id",JDBCType.INTEGER);

    IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
    sqlCriterion<Integer> criterion = sqlCriterion.withColumn(column)
            .withCondition(condition)
            .build();
    AtomicInteger sequence = new AtomicInteger(1);
    FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
            .withSequence(sequence)
            .withRenderingStrategy(RenderingStrategy.MYBATIS3)
            .withTableAliasCalculator(TableAliasCalculator.empty())
            .build()
            .render();

    assertthat(fp.fragment()).isEqualTo("id = #{parameters.p1,jdbcType=INTEGER}");
    assertthat(fp.parameters().size()).isEqualTo(1);
    assertthat(fp.parameters().get("p1")).isEqualTo(3);
}
项目:mybatis-dynamic-sql    文件CriterionRendererTest.java   
@Test
public void testAliasWithoutIgnore() {
    sqlTable table = sqlTable.of("foo");
    sqlColumn<Integer> column = table.column("id",JDBCType.INTEGER);
    IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
    sqlCriterion<Integer> criterion = sqlCriterion.withColumn(column)
            .withCondition(condition)
            .build();
    AtomicInteger sequence = new AtomicInteger(1);

    Map<sqlTable,"a");

    FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
            .withSequence(sequence)
            .withRenderingStrategy(RenderingStrategy.MYBATIS3)
            .withTableAliasCalculator(TableAliasCalculator.of(tableAliases))
            .build()
            .render();

    assertthat(fp.fragment()).isEqualTo("a.id = #{parameters.p1,jdbcType=INTEGER}");
    assertthat(fp.parameters().size()).isEqualTo(1);
    assertthat(fp.parameters().get("p1")).isEqualTo(3);
}
项目:mybatis-dynamic-sql    文件CriterionRendererTest.java   
@Test
public void testNoAliasWithIgnore() {
    sqlTable table = sqlTable.of("foo");
    sqlColumn<Integer> column = table.column("id",JDBCType.INTEGER);
    IsEqualTo<Integer> condition = IsEqualTo.of(() -> 3);
    sqlCriterion<Integer> criterion = sqlCriterion.withColumn(column)
            .withCondition(condition)
            .build();
    AtomicInteger sequence = new AtomicInteger(1);
    FragmentAndParameters fp = CriterionRenderer.withCriterion(criterion)
            .withSequence(sequence)
            .withRenderingStrategy(RenderingStrategy.MYBATIS3)
            .withTableAliasCalculator(TableAliasCalculator.empty())
            .build()
            .render();

    assertthat(fp.fragment()).isEqualTo("id = #{parameters.p1,jdbcType=INTEGER}");
    assertthat(fp.parameters().size()).isEqualTo(1);
    assertthat(fp.parameters().get("p1")).isEqualTo(3);
}
项目:mybatis-dynamic-sql    文件CriterionRendererTest.java   
@Test
public void testNoAliasWithoutIgnore() {
    sqlTable table = sqlTable.of("foo");
    sqlColumn<Integer> column = table.column("id",jdbcType=INTEGER}");
    assertthat(fp.parameters().size()).isEqualTo(1);
    assertthat(fp.parameters().get("p1")).isEqualTo(3);
}
项目:peloton-test    文件Ast.java   
public static ExpressionType fromJDBCType(JDBCType type) {
    // Todo research sql types
    switch (type) {
        case DOUBLE:
        case FLOAT:
        case INTEGER:
        case NUMERIC:
        case DECIMAL:
            return NUMERIC;
        case VARCHAR:
        case LONGNVARCHAR:
            return VARCHAR;
        case BOOLEAN:
            return BOOLEAN;
        default:
            throw new IllegalArgumentException("Unimplemented");
    }
}
项目:Geometry-wars    文件StatementsTest.java   
/**
 * Helper method for *Setobject* tests.
 * Insert data into the given PreparedStatement,cstmt.executeUpdate());

        return 2;
    }

    return 1;
}
项目:tempto    文件InsertLoader.java   
private String asstringValue(JDBCType jdbcType,Object o)
{
    if (o == null) {
        return "null";
    }
    switch (jdbcType) {
        case VARCHAR:
        case CHAR:
        case LONGNVARCHAR:
            return "'" + o.toString() + "'";
        case tinyint:
        case SMALLINT:
        case INTEGER:
        case BIGINT:
        case FLOAT:
        case REAL:
        case DOUBLE:
        case DECIMAL:
            return o.toString();
        default:
            throw new IllegalArgumentException("Unsupported column type for INSERT: " + jdbcType);
    }
}
项目:tempto    文件sqlResultDescriptor.java   
public List<Row> getRows(List<JDBCType> columnTypes)
{
    List<Row> values = newArrayList();
    String delimiter = getColumnDelimiter();

    QueryRowMapper rowMapper = new QueryRowMapper(columnTypes);
    Splitter valuessplitter = Splitter.on(delimiter);
    if (isTrimValues()) {
        valuessplitter = valuessplitter.trimResults();
    }

    for (String line : sqlSectionParsingResult.getContentLines()) {
        List<String> rowValues = parseLine(line,delimiter,valuessplitter);
        values.add(rowMapper.mapToRow(rowValues));
    }

    if (isJoinAllRowsToOne()) {
        checkState(columnTypes.size() == 1,"Expected single column result when 'joinAllRowsToOne' property is set,columnTypes: %s",columnTypes);
        String joinedRows = values.stream()
                .map(row -> String.valueOf(row.getValues().get(0)))
                .collect(joining("\n"));
        return ImmutableList.of(row(joinedRows));
    }

    return values;
}
项目:tempto    文件sqlQueryConventionBasedTest.java   
private void dumpResults(QueryResult queryResult,Path path)
        throws IOException
{
    if (!Files.exists(path)) {
        Files.createDirectory(path);
    }
    checkState(Files.isDirectory(path),"%s have to point to the directory",path);
    String testFileName = queryFile.getFileName().toString();
    String resultsFileName = testFileName.substring(0,testFileName.lastIndexOf(".")) + ".result";

    Path resultFilePath = Paths.get(path.toString(),resultsFileName);
    try (BufferedWriter writer = newBufferedWriter(resultFilePath)) {
        String types = queryResult.getColumnTypes().stream().map(JDBCType::getName).collect(joining("|"));
        writer.write("-- delimiter: |; types: " + types);
        writer.newLine();
        for (List<Object> row : queryResult.rows()) {
            writer.write(new QueryAssert.Row(row).toString());
            writer.newLine();
        }
    }
}
项目:tempto    文件QueryAssert.java   
public <T> QueryAssert column(int columnIndex,JDBCType type,ColumnValuesAssert<T> columnValuesAssert)
{
    if (fromsqlIndex(columnIndex) > actual.getColumnsCount()) {
        failWithMessage("Result contains only <%s> columns,extracting column <%s>",actual.getColumnsCount(),columnIndex);
    }

    JDBCType actualColumnType = actual.getColumnType(columnIndex);
    if (!type.equals(actualColumnType)) {
        failWithMessage("Expected <%s> column,to be type: <%s>,but was: <%s>",columnIndex,type,actualColumnType);
    }

    List<T> columnValues = actual.column(columnIndex);

    columnValuesAssert.assertColumnValues(Assertions.assertthat(columnValues));

    return this;
}
项目:presto    文件ShardPredicate.java   
public static JDBCType jdbcType(Type type)
{
    if (type.equals(BooleanType.BOOLEAN)) {
        return JDBCType.BOOLEAN;
    }
    if (type.equals(BigintType.BIGINT) || type.equals(TimestampType.TIMESTAMP)) {
        return JDBCType.BIGINT;
    }
    if (type.equals(DoubleType.DOUBLE)) {
        return JDBCType.DOUBLE;
    }
    if (type.equals(DateType.DATE)) {
        return JDBCType.INTEGER;
    }
    if (type.equals(VarcharType.VARCHAR)) {
        return JDBCType.VARBINARY;
    }
    return null;
}
项目:presto    文件DatabaseShardManager.java   
private static String sqlColumnType(Type type)
{
    JDBCType jdbcType = jdbcType(type);
    if (jdbcType != null) {
        switch (jdbcType) {
            case BOOLEAN:
                return "boolean";
            case BIGINT:
                return "bigint";
            case DOUBLE:
                return "double";
            case INTEGER:
                return "int";
            case VARBINARY:
                return format("varbinary(%s)",MAX_BINARY_INDEX_SIZE);
        }
    }
    return null;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。