当前位置: 首页>>代码示例>>Java>>正文


Java JDBCType类代码示例

本文整理汇总了Java中java.sql.JDBCType的典型用法代码示例。如果您正苦于以下问题:Java JDBCType类的具体用法?Java JDBCType怎么用?Java JDBCType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JDBCType类属于java.sql包,在下文中一共展示了JDBCType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertTestDataOffsetDTTypes

import java.sql.JDBCType; //导入依赖的package包/类
/**
 * 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", testOffsetTime, JDBCType.VARCHAR);
        cstmt.setObject("ot2", testOffsetTime);
        cstmt.setObject("odt1", testOffsetDateTime, JDBCType.VARCHAR);
        cstmt.setObject("odt2", testOffsetDateTime);
        assertEquals(1, cstmt.executeUpdate());

        return 2;
    }

    return 1;
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:37,代码来源:StatementsTest.java

示例2: getJDBCInfoByColumnNames

import java.sql.JDBCType; //导入依赖的package包/类
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, schema, tableName.toLowerCase(), columnName.toLowerCase());
        }
        column.next();
        param.setJdbcType(JDBCType.valueOf(column.getInt("DATA_TYPE")));
        paramList.add(param);
    }
    return paramList;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:18,代码来源:DatabaseMetaDataHelper.java

示例3: toSqlType

import java.sql.JDBCType; //导入依赖的package包/类
/**
 * {@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;
		}
	};
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:30,代码来源:Parameter.java

示例4: setStreamParameter

import java.sql.JDBCType; //导入依赖的package包/类
/**
 * ステートメントにストリームパラメータを登録。
 *
 * @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, stream, len);
		} else {
			preparedStatement.setAsciiStream(index, stream);
		}
	} else {
		return super.setParameter(preparedStatement, index, parameterMapperManager);
	}

	parameterLog(index);
	index++;

	return index;
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:34,代码来源:StreamParameter.java

示例5: testExecuteUpdate

import java.sql.JDBCType; //导入依赖的package包/类
/**
 * 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", 0, 1).stream(new MapResultSetConverter(CaseFormat.LOWER_SNAKE_CASE))
			.collect(Collectors.toList());

	assertEquals(expectedDataList.toString(), actualDataList.toString());
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:25,代码来源:SqlAgentTest.java

示例6: testUpdateFluent

import java.sql.JDBCType; //导入依赖的package包/类
/**
 * 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", new BigDecimal("0"), JDBCType.DECIMAL)
			.param("jan_code", "1234567890123", Types.CHAR).count();
	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", 0, 1).stream(new MapResultSetConverter(CaseFormat.LOWER_SNAKE_CASE))
			.collect(Collectors.toList());

	assertEquals(expectedDataList.toString(), actualDataList.toString());
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:23,代码来源:SqlAgentTest.java

示例7: testExecuteUpdateFilter

import java.sql.JDBCType; //导入依赖的package包/类
@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", new BigDecimal("0"), JDBCType.DECIMAL)
				.param("jan_code", "1234567890123", Types.CHAR);
		agent.update(ctx);
	});

	assertThat(log,
			is(Files.readAllLines(
					Paths.get("src/test/resources/data/expected/DebugSqlFilter", "testExecuteUpdateFilter.txt"),
					StandardCharsets.UTF_8)));
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:17,代码来源:DebugSqlFilterTest.java

示例8: rowsetUsingDataTypes

import java.sql.JDBCType; //导入依赖的package包/类
@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}
    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:CommonCachedRowSetTests.java

示例9: compareRowSets

import java.sql.JDBCType; //导入依赖的package包/类
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);
            }
        }

    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:CommonCachedRowSetTests.java

示例10: testNull

import java.sql.JDBCType; //导入依赖的package包/类
@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", null, 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(), null, Utils.TYPE_FORM_URLENCODED, String.join("&",
            Utils.queryParam("query", "select ?s ?p ?o where {?s ?p ?o.} limit 10"),
            Utils.queryParam("$p", "\"not-null\"")));
}
 
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:22,代码来源:CallableStatementTest.java

示例11: testNull

import java.sql.JDBCType; //导入依赖的package包/类
@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, Types.VARCHAR, "IGNORED");
    statement.setObject(++index, null);
    statement.setObject(++index, null, Types.INTEGER);
    statement.setObject(++index, null, JDBCType.INTEGER);
    statement.setString(++index, null);
    statement.setTime(++index, null);
    statement.setTimestamp(++index, null);
    statement.setURL(++index, null);
    statement.execute();
    verify(lastBackendRequest).handle(Method.POST, sql.urlPath(), null, Utils.TYPE_FORM_URLENCODED, String.join("&",
            Utils.queryParam("query", "select * from Fielding where yearid in (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"),
            Utils.queryParam("$data_world_param0", "\"not-null\"")));
}
 
开发者ID:datadotworld,项目名称:dw-jdbc,代码行数:23,代码来源:PreparedStatementTest.java

示例12: testAliasWithIgnore

import java.sql.JDBCType; //导入依赖的package包/类
@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);
    });
}
 
开发者ID:mybatis,项目名称:mybatis-dynamic-sql,代码行数:23,代码来源:CriterionRendererTest.java

示例13: testAliasWithoutIgnore

import java.sql.JDBCType; //导入依赖的package包/类
@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);
    });
}
 
开发者ID:mybatis,项目名称:mybatis-dynamic-sql,代码行数:24,代码来源:CriterionRendererTest.java

示例14: testNoAliasWithIgnore

import java.sql.JDBCType; //导入依赖的package包/类
@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);
    });
}
 
开发者ID:mybatis,项目名称:mybatis-dynamic-sql,代码行数:22,代码来源:CriterionRendererTest.java

示例15: testNoAliasWithoutIgnore

import java.sql.JDBCType; //导入依赖的package包/类
@Test
public void testNoAliasWithoutIgnore() {
    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);
    });
}
 
开发者ID:mybatis,项目名称:mybatis-dynamic-sql,代码行数:22,代码来源:CriterionRendererTest.java


注:本文中的java.sql.JDBCType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。