Package Hierarchy
-
core:JdbcTemplate 类,可在基本 JDBC 处理、错误处理和JDBC 批量操作中使用。
-
datasource:用于简化数据源访问和为测试和运行独立 JDBC 代码提供数据源实现的实用程序。
-
object:将 RDBMS 查询、更新和存储过程表示为线程安全、可重用对象的类。
-
support:提供 SQLException 转换功能和实用程序类,通过将 JDBC 异常转换为 org.springframework.dao 包中的异常,简化错误处理。
Spring 框架的 JDBC 抽象框架由以下四个不同的包组成:
The Spring Framework’s JDBC abstraction framework consists of four different packages:
-
core
: Theorg.springframework.jdbc.core
package contains theJdbcTemplate
class and its various callback interfaces, plus a variety of related classes. A subpackage namedorg.springframework.jdbc.core.simple
contains theSimpleJdbcInsert
andSimpleJdbcCall
classes. Another subpackage namedorg.springframework.jdbc.core.namedparam
contains theNamedParameterJdbcTemplate
class and the related support classes. See Using the JDBC Core Classes to Control Basic JDBC Processing and Error Handling, JDBC Batch Operations, and Simplifying JDBC Operations with theSimpleJdbc
Classes. -
datasource
: Theorg.springframework.jdbc.datasource
package contains a utility class for easyDataSource
access and various simpleDataSource
implementations that you can use for testing and running unmodified JDBC code outside of a Jakarta EE container. A subpackage namedorg.springframework.jdbc.datasource.embedded
provides support for creating embedded databases by using Java database engines, such as HSQL, H2, and Derby. See Controlling Database Connections and Embedded Database Support. -
object
: Theorg.springframework.jdbc.object
package contains classes that represent RDBMS queries, updates, and stored procedures as thread-safe, reusable objects. See Modeling JDBC Operations as Java Objects. This style results in a more object-oriented approach, although objects returned by queries are naturally disconnected from the database. This higher-level of JDBC abstraction depends on the lower-level abstraction in theorg.springframework.jdbc.core
package. -
support
: Theorg.springframework.jdbc.support
package providesSQLException
translation functionality and some utility classes. Exceptions thrown during JDBC processing are translated to exceptions defined in theorg.springframework.dao
package. This means that code using the Spring JDBC abstraction layer does not need to implement JDBC or RDBMS-specific error handling. All translated exceptions are unchecked, which gives you the option of catching the exceptions from which you can recover while letting other exceptions be propagated to the caller. See UsingSQLExceptionTranslator
.