4 JDBC Data Access with Spring
WHAT YOU WILL LEARN IN THIS CHAPTER:
- Problems with using vanilla JDBC access
- Advantages of Spring's JDBC support
- Configuring and using Spring's JDBC support
- Properly handling and translating SQLExceptions and SQL error codes
- Configuring and managing connections and initializing the database
- Performing queries and batch operations, updating databases, accessing native JDBC methods, and calling stored procedures
- Modeling JDBC operations as Java objects
You can use various data access technologies to perform persistence operations, and JDBC is among the first used in enterprise applications. However, using JDBC directly has some drawbacks, and this chapter first focuses on the problems of using vanilla JDBC. The starting point of using Spring JDBC support is to define a DataSource bean, and you learn about several different methods for creating a DataSource within your application or obtaining one managed by your application server through JNDI lookup. This chapter also explains how to initialize a database by populating data during system bootstrap.
Later in the chapter you are introduced to Spring's JDBC support. The chapter explains and gives examples of several of its uses, such as executing queries; ...
Get Beginning Spring now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.