api-docs / org.ktorm.database / Database / connect
connect
fun connect(
dialect: SqlDialect = detectDialectImplementation(),
logger: Logger = detectLoggerImplementation(),
alwaysQuoteIdentifiers: Boolean = false,
generateSqlInUpperCase: Boolean? = null,
connector: () -> Connection
): Database
(source code)Connect to a database by a specific connector function.
Parameters
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.
connector
- the connector function used to obtain SQL connections.
Return
the new-created database object.
fun connect(
dataSource: DataSource,
dialect: SqlDialect = detectDialectImplementation(),
logger: Logger = detectLoggerImplementation(),
alwaysQuoteIdentifiers: Boolean = false,
generateSqlInUpperCase: Boolean? = null
): Database
(source code)Connect to a database using a DataSource.
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.
fun connect(
url: String,
driver: String? = null,
user: String? = null,
password: String? = null,
dialect: SqlDialect = detectDialectImplementation(),
logger: Logger = detectLoggerImplementation(),
alwaysQuoteIdentifiers: Boolean = false,
generateSqlInUpperCase: Boolean? = null
): Database
(source code)Connect to a database using the specific connection arguments.
Parameters
url
- the URL of the database to be connected.
driver
- the full qualified name of the JDBC driver class.
user
- the username of the database.
password
- the password of the database.
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.