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


Java JdbcTestUtils.deleteFromTables方法代码示例

本文整理汇总了Java中org.springframework.test.jdbc.JdbcTestUtils.deleteFromTables方法的典型用法代码示例。如果您正苦于以下问题:Java JdbcTestUtils.deleteFromTables方法的具体用法?Java JdbcTestUtils.deleteFromTables怎么用?Java JdbcTestUtils.deleteFromTables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.test.jdbc.JdbcTestUtils的用法示例。


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

示例1: ddlOrDelete

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
private void ddlOrDelete() {
    try {

        final int pathsCount = JdbcTestUtils.countRowsInTable(jdbcTemplate, NAMES_TABLE);
        if (pathsCount > 0) {
            JdbcTestUtils.deleteFromTables(jdbcTemplate, NAMES_TABLE);
        }

    } catch (BadSqlGrammarException e) {
        switch (e.getSQLException().getErrorCode()) {
            case ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1:

                jdbcTemplate.execute(new StringBuilder()
                        .append("CREATE TABLE ").append(NAMES_TABLE).append(" (\n")
                        .append(" id INT PRIMARY KEY,\n")
                        .append(" name VARCHAR,\n")
                        .append(" automat VARCHAR\n")
                        .append(");").toString());

                break;
            default:
                throw e;
        }
    }
}
 
开发者ID:bedla,项目名称:parkovani-v-praze,代码行数:26,代码来源:GeoCodingController.java

示例2: doTearDown

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
public final void doTearDown() {
	try {
		solrServer.deleteByQuery("*:*");
		JdbcTestUtils.deleteFromTables(jdbc, tableNames());
	} catch (SolrServerException | IOException e) {
		logger.error("Error tearing down test data");
		e.printStackTrace();
	}
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:10,代码来源:AbstractPersistenceTest.java

示例3: beforeTestClass

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Override
public void beforeTestClass(TestContext testContext) throws Exception {
    ApplicationContext applicationContext = testContext.getApplicationContext();
    DataSource dataSource = applicationContext.getBean("dataSource", DataSource.class);
    JdbcTestUtils.deleteFromTables(new JdbcTemplate(dataSource), "claim");
}
 
开发者ID:hmcts,项目名称:cmc-claim-store,代码行数:7,代码来源:BaseIntegrationTest.java

示例4: setUp

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Before
public void setUp() {
    JdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "SERVICETICKET");
    JdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "TICKETGRANTINGTICKET");
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:6,代码来源:JpaTicketRegistryTests.java

示例5: deleteFromTables

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
protected int deleteFromTables(String... names) {
	return JdbcTestUtils.deleteFromTables(this.jdbcTemplate, names);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:ProgrammaticTxMgmtTests.java

示例6: savePathsIntoDb

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
private void savePathsIntoDb(List<Path> paths) throws SQLException {
        LOG.info("--- savePathsIntoDb ---");

        try {

            final int pathsCount = JdbcTestUtils.countRowsInTable(jdbcTemplate, PATHS_TABLE);
            if (pathsCount > 0) {
                JdbcTestUtils.deleteFromTables(jdbcTemplate, PATHS_TABLE);
            }

        } catch (BadSqlGrammarException e) {
            switch (e.getSQLException().getErrorCode()) {
                case ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1:

                    jdbcTemplate.execute(new StringBuilder()
                            .append("CREATE TABLE ").append(PATHS_TABLE).append(" (\n")
                            .append(" id INT PRIMARY KEY AUTO_INCREMENT,\n")
                            .append(" source_uid INT,\n")
                            .append(" target_uid INT,\n")
                            .append(" distance DOUBLE,\n")
                            .append(" bbox VARCHAR,\n")
                            .append(" weight DOUBLE,\n")
                            .append(" time INT,\n")
                            .append(" points CLOB\n")
                            .append(");").toString());

                    jdbcTemplate.execute(String.format("CREATE UNIQUE INDEX IDX_source_target ON %s (source_uid, target_uid);", PATHS_TABLE));
                    jdbcTemplate.execute(String.format("CREATE INDEX IDX_source_uid ON %s (source_uid);", PATHS_TABLE));
                    jdbcTemplate.execute(String.format("CREATE INDEX IDX_target_uid ON %s (target_uid);", PATHS_TABLE));
                    jdbcTemplate.execute(String.format("CREATE INDEX IDX_distance ON %s (distance);", PATHS_TABLE));
                    jdbcTemplate.execute(String.format("CREATE INDEX IDX_time ON %s (time);", PATHS_TABLE));

                    break;
                default:
                    throw e;
            }
        }

        final String insertSql = "INSERT INTO " + PATHS_TABLE + " (source_uid, target_uid, distance, bbox, weight, time, points) VALUES (?, ?, ?, ?, ?, ?, ?)";
        jdbcTemplate.batchUpdate(insertSql, paths, paths.size(), (ps, argument) -> {
            ps.setInt(1, argument.source.uid);
            ps.setInt(2, argument.target.uid);
            ps.setDouble(3, argument.distance);
            ps.setString(4, Joiner.on(',').join(argument.bbox));
            ps.setDouble(5, argument.weight);
            ps.setInt(6, argument.time);
            ps.setString(7, argument.points);
        });


//        System.out.println(JdbcTestUtils.countRowsInTable(jdbcTemplate, PATHS_TABLE));
//        List<Map<String, Object>> list = jdbcTemplate.queryForList("SELECT * FROM " + PATHS_TABLE);
//        for (Map<String, Object> map : list) {
//            System.out.println(map);
//        }
    }
 
开发者ID:bedla,项目名称:parkovani-v-praze,代码行数:57,代码来源:GraphDataLoaderController.java

示例7: beforeTestMethod

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
@Override
public void beforeTestMethod(final TestContext testContext) throws Exception {
    JdbcTestUtils.deleteFromTables(getJdbcTemplate(testContext.getApplicationContext()), "pets", "people");

    log.info("Deleted data from tables: 'pets', 'people'...");
}
 
开发者ID:cjstehno,项目名称:sjdbcx,代码行数:7,代码来源:DatabaseTestExecutionListener.java

示例8: afterPropertiesSet

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
/**
 * One-time test initialization.
 *
 * @throws Exception On setup errors.
 */
public void afterPropertiesSet() throws Exception {
    JdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "locks");
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:9,代码来源:JpaLockingStrategyTests.java

示例9: deleteFromTables

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
/**
 * Convenience method for deleting all rows from the specified tables.
 * <p>Use with caution outside of a transaction!
 * @param names the names of the tables from which to delete
 * @return the total number of rows deleted from all specified tables
 * @see JdbcTestUtils#deleteFromTables
 */
protected int deleteFromTables(String... names) {
	return JdbcTestUtils.deleteFromTables(this.jdbcTemplate, names);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:AbstractTransactionalTestNGSpringContextTests.java

示例10: deleteFromTables

import org.springframework.test.jdbc.JdbcTestUtils; //导入方法依赖的package包/类
/**
 * Convenience method for deleting all rows from the specified tables. Use
 * with caution outside of a transaction!
 * @param names the names of the tables from which to delete
 * @return the total number of rows deleted from all specified tables
 */
protected int deleteFromTables(String... names) {
	return JdbcTestUtils.deleteFromTables(this.jdbcTemplate, names);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:AbstractTransactionalTestNGSpringContextTests.java


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