Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

H3. What is Spring JDBC?
Spring JDBC is an abstraction framework for JDBC that provides easier access to datasources without all the exception handling and parsing of SQL fetch results. Spring JDBC basically does lots of things for you.

Main spring JDBC page: http://www.springframework.org/docs/reference/jdbc.html
Using Spring JDBC over regular JDBC: http://today.java.net/pub/a/today/2006/05/09/why-spring-jdbc.html

Sample Spring JDBC code in Sakai

TaskListManagerJdbcImpl.java
This code sample demonstrates a working Spring JDBC implementation of the Tasklist Manager

Strengths of Spring JDBC

  • Spring provides an abstract exception layer, moving verbose and error-prone exception handling out of application code into the framework. The framework takes care of all exception handling; application code can concentrate on extracting results by using appropriate SQL.
  • Spring provides a significant exception hierarchy for your application code to work with in place of SQLException.
  • The Spring framework provides the org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor interface and some implementations (such as SimpleNativeJdbcExtractor) of this interface. These are useful for accessing Oracle features via an Oracle connection or ResultSet when the connection is "wrapped" by another DataSource (such as that used with some application servers) or obtained through certain connection pools.
  • For creating instances of oracle.sql.BLOB (binary large object) and oracle.sql.CLOB(character large object), Spring provides the class org.springframework.jdbc.support.lob.OracleLobHandler.
  • The Spring-provided OracleSequenceMaxValueIncrementer class provides the next value of an Oracle sequence. It effectively provides the same information that would be provided if you used the following command directly: select someSequence.nextval from dual (where someSequence is the name of your sequence in the Oracle database). An advantage of this approach is that the DataFieldMaxValueIncrementer interface can be used in a DAO hierarchy without tight coupling of the Oracle-specific implementation.
  • No labels