spring-framework / org.springframework.jdbc.support / JdbcAccessor

JdbcAccessor

abstract class JdbcAccessor : InitializingBean

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

Not intended to be used directly. See org.springframework.jdbc.core.JdbcTemplate.

Author
Juergen Hoeller

Since
28.11.2003

See Also
org.springframework.jdbc.core.JdbcTemplate

Constructors

<init>

JdbcAccessor()

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

Not intended to be used directly. See org.springframework.jdbc.core.JdbcTemplate.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

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

getDataSource

open fun getDataSource(): DataSource

Return the DataSource used by this template.

getExceptionTranslator

open fun getExceptionTranslator(): SQLExceptionTranslator

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.

isLazyInit

open fun isLazyInit(): Boolean

Return whether to lazily initialize the SQLExceptionTranslator for this accessor.

setDataSource

open fun setDataSource(dataSource: DataSource): Unit

Set the JDBC DataSource to obtain connections from.

setDatabaseProductName

open fun setDatabaseProductName(dbName: String): Unit

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.

setExceptionTranslator

open fun setExceptionTranslator(exceptionTranslator: SQLExceptionTranslator): Unit

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.

setLazyInit

open fun setLazyInit(lazyInit: Boolean): Unit

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.