English | 简体中文

api-docs / org.ktorm.database / Database / connectWithSpringSupport

connectWithSpringSupport

fun connectWithSpringSupport(
    dataSource: DataSource,
    dialect: SqlDialect = detectDialectImplementation(),
    logger: Logger = detectLoggerImplementation(),
    alwaysQuoteIdentifiers: Boolean = false,
    generateSqlInUpperCase: Boolean? = null
): Database
(source code)

Connect to a database using a DataSource with the Spring support enabled.

Once the Spring support is enabled, the transaction management will be delegated to the Spring framework,
so the useTransaction function is not available anymore, we need to use Spring’s Transactional
annotation instead.

This function also enables the exception translation, which can convert any SQLException thrown by JDBC
to Spring’s DataAccessException and rethrow it.

Parameters

dataSource - the data source used to obtain SQL connections.

dialect - the dialect, auto-detects an implementation by default using JDK ServiceLoader facility.

logger - logger used to output logs, auto-detects an implementation by default.

alwaysQuoteIdentifiers - whether we need to always quote SQL identifiers in the generated SQLs.

generateSqlInUpperCase - whether we need to output the generated SQLs in upper case.

Return
the new-created database object.