org.springframework.jdbc.support
Class JdbcAccessor

Direct Known Subclasses:
JdbcTemplate, SqlMapTemplate

public class JdbcAccessor

Base class for JdbcTemplate and other JDBC-accessing DAO helpers, defining common properties like exception translator.

Not intended to be used directly. See JdbcTemplate.

Author:
Juergen Hoeller
Since: 28.11.2003
See Also: JdbcTemplate

Method Summary
 voidafterPropertiesSet()
          Eagerly initialize the exception translator, creating a default one for the specified DataSource if none set.
 DataSourcegetDataSource()
          Return the DataSource used by this template.
 synchronized SQLExceptionTranslatorgetExceptionTranslator()
          Return the exception translator for this instance.
 voidsetDataSource(DataSource dataSource)
          Set the JDBC DataSource to obtain connections from.
 voidsetExceptionTranslator(SQLExceptionTranslator exceptionTranslator)
          Set the exception translator for this instance.

Method Detail

afterPropertiesSet

public void afterPropertiesSet()
Eagerly initialize the exception translator, creating a default one for the specified DataSource if none set.

getDataSource

public DataSource getDataSource()
Return the DataSource used by this template.

getExceptionTranslator

public synchronized SQLExceptionTranslator getExceptionTranslator()
Return the exception translator for this instance. Creates a default one for the specified DataSource if none set.

setDataSource

public void setDataSource(DataSource dataSource)
Set the JDBC DataSource to obtain connections from.

setExceptionTranslator

public void setExceptionTranslator(SQLExceptionTranslator exceptionTranslator)
Set the exception translator for this instance. If no custom translator is provided, a default is used which examines the SQLException's vendor-specific error code.
Parameters:
exceptionTranslator - exception translator
See Also:
SQLErrorCodeSQLExceptionTranslator, SQLStateSQLExceptionTranslator

Association Links

to Class javax.sql.DataSource

Used to obtain connections throughout the lifecycle of this object. This enables this class to close connections if necessary.

to Class org.springframework.jdbc.support.SQLExceptionTranslator

Helper to translate SQL exceptions to DataAccessExceptions