connect

fun connect(datasource: DataSource, setupConnection: (Connection) -> Unit = {}, databaseConfig: DatabaseConfig? = null, 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.

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, 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.

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, 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.

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.