public abstract class

JdbcAccessor

extends Object
implements InitializingBean
java.lang.Object
   ↳ org.springframework.jdbc.support.JdbcAccessor
Known Direct Subclasses

Class Overview

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

Not intended to be used directly. See JdbcTemplate.

See Also

Summary

Fields
protected final Log logger Logger available to subclasses
Public Constructors
JdbcAccessor()
Public Methods
void afterPropertiesSet()
Eagerly initialize the exception translator, if demanded, creating a default one for the specified DataSource if none set.
DataSource getDataSource()
Return the DataSource used by this template.
synchronized SQLExceptionTranslator getExceptionTranslator()
Return the exception translator for this instance.
boolean isLazyInit()
Return whether to lazily initialize the SQLExceptionTranslator for this accessor.
void setDataSource(DataSource dataSource)
Set the JDBC DataSource to obtain connections from.
void setDatabaseProductName(String dbName)
Specify the database product name for the DataSource that this accessor uses.
void setExceptionTranslator(SQLExceptionTranslator exceptionTranslator)
Set the exception translator for this instance.
void setLazyInit(boolean lazyInit)
Set whether to lazily initialize the SQLExceptionTranslator for this accessor, on first encounter of a SQLException.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.beans.factory.InitializingBean

Fields

protected final Log logger

Logger available to subclasses

Public Constructors

public JdbcAccessor ()

Public Methods

public void afterPropertiesSet ()

Eagerly initialize the exception translator, if demanded, creating a default one for the specified DataSource if none set.

public DataSource getDataSource ()

Return the DataSource used by this template.

public synchronized SQLExceptionTranslator getExceptionTranslator ()

Return the exception translator for this instance.

Creates a default SQLErrorCodeSQLExceptionTranslator for the specified DataSource if none set, or a SQLStateSQLExceptionTranslator in case of no DataSource.

See Also

public boolean isLazyInit ()

Return whether to lazily initialize the SQLExceptionTranslator for this accessor.

public void setDataSource (DataSource dataSource)

Set the JDBC DataSource to obtain connections from.

public void setDatabaseProductName (String dbName)

Specify the database product name for the DataSource that this accessor uses. This allows to initialize a SQLErrorCodeSQLExceptionTranslator without obtaining a Connection from the DataSource to get the metadata.

Parameters
dbName the database product name that identifies the error codes entry

public void setExceptionTranslator (SQLExceptionTranslator exceptionTranslator)

Set the exception translator for this instance.

If no custom translator is provided, a default SQLErrorCodeSQLExceptionTranslator is used which examines the SQLException's vendor-specific error code.

public void setLazyInit (boolean lazyInit)

Set whether to lazily initialize the SQLExceptionTranslator for this accessor, on first encounter of a SQLException. Default is "true"; can be switched to "false" for initialization on startup.

Early initialization just applies if afterPropertiesSet() is called.