Thomas Risberg, Consultant, springdeveloper.com
Rob Harrop, Principal Consultant, Interface21
Date: Monday, August 1st, 2005
Time: 8:30am - 12:00pm
The Spring Framework is an application framework that covers many different layers of Java and J2EE application development. For this talk, we will concentrate on the parts that deal with database access.
Most applications access a database and the standard API for this is JDBC. This is a low level API that is cumbersome to work with and it is easy to make a mistake whereby connections are not closed. This can easily lead to application failures and downtime.
The Spring Framework provides an abstraction layer that manages all the JDBC resources and automatically closes them. This leads to significantly fewer lines of code with fewer errors as well. In addition to this the Spring Framework provides declarative transaction support for any application, not just EJBs. This makes it possible to use the same code in a variety of environments without having to recode the transaction aspects of the code.
This talk focuses on how to get started with the Spring Framework. It shows an example application and how to configure a Spring application context with the necessary Spring JDBC components. We will replace the standard JDBC code in the application with its Spring equivalent.
Next we will cover more advanced features like customized exception translation, batch updates, stored procedure access and BLOB/CLOB support. We will also look at an example of declarative transaction configuration.
The final part will discuss when JDBC is more appropriate and when an O/R Mapping tool like Hibernate would be better. An example of how to mix both Hibernate and JDBC within the same transaction is also shown.