Spring and JDBC
The Spring supports the following two types of transaction management.
Programmatic Transaction Management: In this type of transaction management, you will manage the transaction in your code. This transaction management provide you extreme flexibility and at the other end it is hard to manage and maintain.
Declarative Transaction Management: In this transaction management, the business code is separated from the transaction management. The XML based configuration or annotations
A sequence of actions which make a single work unit is a database transaction. This sequence of actions must be completely taken effect or discarded at all. The most important part of RDBMS based enterprise applications is transaction management which ensure consistency and data integrity. Following are the four main properties of transactions which explain it.
Atomicity: A single unit of operation best describes the transaction. So that is either successful or not as a single unit of operation.
Following functions are performed by JdbcTemplate class.
Execute update statements
Stored procedure calls
Returned parameter extraction
Cache JDBC exceptions
Transalation of JDBC exceptions into generic and informative exceptions that are defined in spring dao package
Once JdbcTemplate instance are configured, they are thread safe. It is possible to use a single JdbcTemplate
It is cumbersome to write useless and unnecessary code when working with the database using old JDBC which is old and plain to handle database connections and exceptions etc. All the minor details are handled by the Spring JDBC framework like open a database connection, prepare a SQL statement, execute a SQL statement, handle transactions, process exception and close a database connection.
You job is to only define the parameters for database connections and SQL statements so that
In our next tip, I will focus on Springs data access support. Spring uses the design pattern, data access object (DAO). The purpose of DAOs is to provide means to read and write data to the database. So what Spring has focused on is to make it easy for developers to write DAOs as irrespective of whether you use JDBC, Hibernate, JPA or JDO. The way in which it does this is by separating the interface from the data access implementation. Therefore the implementation can change to align with the