connect

fun connect(datasource: DataSource, setupConnection: (Connection) -> Unit = {}, databaseConfig: DatabaseConfig? = null, connectionAutoRegistration: DatabaseConnectionAutoRegistration = connectionInstanceImpl, manager: (Database) -> TransactionManager = { ThreadLocalTransactionManager(it) }): Database

Creates a Database instance.

Note: This function does not immediately instantiate an actual connection to a database, but instead provides the details necessary to do so whenever a connection is required by a transaction.

Parameters

datasource

The DataSource object to be used as a means of getting a connection.

connectionAutoRegistration

The connection provider for database. If not provided, a service loader will be used to locate and load a provider for DatabaseConnectionAutoRegistration.

setupConnection

Any setup that should be applied to each new connection.

databaseConfig

Configuration parameters for this Database instance.

manager

The TransactionManager responsible for new transactions that use this Database instance.


fun connect(getNewConnection: () -> Connection, databaseConfig: DatabaseConfig? = null, connectionAutoRegistration: DatabaseConnectionAutoRegistration = connectionInstanceImpl, manager: (Database) -> TransactionManager = { ThreadLocalTransactionManager(it) }): Database

Creates a Database instance.

Note: This function does not immediately instantiate an actual connection to a database, but instead provides the details necessary to do so whenever a connection is required by a transaction.

Parameters

getNewConnection

A function that returns a new connection.

connectionAutoRegistration

The connection provider for database. If not provided, a service loader will be used to locate and load a provider for DatabaseConnectionAutoRegistration.

databaseConfig

Configuration parameters for this Database instance.

manager

The TransactionManager responsible for new transactions that use this Database instance.


fun connect(url: String, driver: String = getDriver(url), user: String = "", password: String = "", setupConnection: (Connection) -> Unit = {}, databaseConfig: DatabaseConfig? = null, connectionAutoRegistration: DatabaseConnectionAutoRegistration = connectionInstanceImpl, manager: (Database) -> TransactionManager = { ThreadLocalTransactionManager(it) }): Database

Creates a Database instance.

Note: This function does not immediately instantiate an actual connection to a database, but instead provides the details necessary to do so whenever a connection is required by a transaction.

Parameters

url

The URL that represents the database when getting a connection.

connectionAutoRegistration

The connection provider for database. If not provided, a service loader will be used to locate and load a provider for DatabaseConnectionAutoRegistration.

driver

The JDBC driver class. If not provided, the specified url will be used to find a match from the existing driver mappings.

user

The database user that owns the new connections.

password

The password specific for the database user.

setupConnection

Any setup that should be applied to each new connection.

databaseConfig

Configuration parameters for this Database instance.

manager

The TransactionManager responsible for new transactions that use this Database instance.