Data Access with JDBC

Spring Framework JDBC 抽象提供的价值可能由下表概述的系列操作最能体现。该表显示了 Spring 处理哪些操作以及哪些操作是你责任。

The value provided by the Spring Framework JDBC abstraction is perhaps best shown by the sequence of actions outlined in the following table below. The table shows which actions Spring takes care of and which actions are your responsibility.

Table 1. Spring JDBC - who does what?
Action Spring You

Define connection parameters.

X

Open the connection.

X

Specify the SQL statement.

X

Declare parameters and provide parameter values

X

Prepare and run the statement.

X

Set up the loop to iterate through the results (if any).

X

Do the work for each iteration.

X

Process any exception.

X

Handle transactions.

X

Close the connection, the statement, and the resultset.

X

Spring Framework 处理所有低级别详细信息,这些详细信息可能会使 JDBC 成为一个繁琐的 API。

The Spring Framework takes care of all the low-level details that can make JDBC such a tedious API.