# Companion

object Companion

## Functions

connect
Link copied to clipboard
fun connect(getNewConnection: () -> Connection, databaseConfig: DatabaseConfig? = null, manager: (Database) -> TransactionManager = { ThreadLocalTransactionManager(it) }): Database
fun connect(datasource: DataSource, setupConnection: (Connection) -> Unit = {}, databaseConfig: DatabaseConfig? = null, manager: (Database) -> TransactionManager = { ThreadLocalTransactionManager(it) }): Database
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.

connectPool
Link copied to clipboard
fun connectPool(datasource: ConnectionPoolDataSource, setupConnection: (Connection) -> Unit = {}, databaseConfig: DatabaseConfig? = null, manager: (Database) -> TransactionManager = { ThreadLocalTransactionManager(it) }): Database

JDBC driver implementations of `ConnectionPoolDataSource` are not actual connection pools, but rather a means of obtaining the physical connections to then be used in a connection pool. It is a known issue, with no plans to be fixed, that `SQLiteConnectionPoolDataSource`, for example, creates a new connection each time instead of retrieving a pooled connection. Other implementations, like `PGConnectionPoolDataSource`, suggest that a `DataSource` or a dedicated third-party connection pool library should be used instead.

getDefaultIsolationLevel
Link copied to clipboard
fun getDefaultIsolationLevel(db: Database): Int

Returns the stored default transaction isolation level for a specific database.

getDialectName
Link copied to clipboard
fun getDialectName(url: String): String?

Returns the database name used internally for the provided connection url.

registerDialect
Link copied to clipboard
fun registerDialect(prefix: String, dialect: () -> DatabaseDialect)

Registers a new DatabaseDialect with the identifier prefix.

registerJdbcDriver
Link copied to clipboard
fun registerJdbcDriver(prefix: String, driverClassName: String, dialect: String)

Registers a new JDBC driver, using the specified driverClassName, with the identifier prefix.