> For the complete documentation index, see [llms.txt](https://docs.flydean.com/spring-framework-documentation5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flydean.com/spring-framework-documentation5/testing/integration-testing/3.3jdbc-testing-support.md).

# 3.3JDBC测试支持

org.springframework.test.jdbc包中包含JdbcTestUtils，它是与JDBC相关的实用程序函数的集合，旨在简化标准数据库测试方案。具体来说，JdbcTestUtils提供以下静态实用程序方法。

* countRowsInTable（..）：计算给定表中的行数。
* countRowsInTableWhere（..）：使用提供的WHERE子句计算给定表中的行数。
* deleteFromTables（..）：删除指定表中的所有行。
* deleteFromTableWhere（..）：使用提供的WHERE子句从给定的表中删除行。
* dropTables（..）：删除指定的表。

> AbstractTransactionalJUnit4SpringContextTests和AbstractTransactionalTestNGSpringContextTests提供了方便的方法，可以委托JdbcTestUtils中的上述方法。
>
> spring-jdbc模块支持配置和启动嵌入式数据库，你可以在与数据库交互的集成测试中使用它。有关详细信息，请参阅嵌入式数据库支持和使用嵌入式数据库测试数据访.
