DBConnection

trait DBConnection extends LogSupport with LoanPattern with AutoCloseable

Basic Database Accessor which holds a JDBC connection.

Companion
object
trait AutoCloseable
trait LogSupport
class Object
trait Matchable
class Any
class DB
class NamedDB

Type members

Inherited types

type Closable = { def close(): Unit; }
Inherited from
LoanPattern

Value members

Abstract methods

def conn: Connection

Returns current JDBC connection.

Returns current JDBC connection.

Concrete methods

def autoClose(autoClose: Boolean): DBConnection

Switches auto close mode.

Switches auto close mode.

Value Params
autoClose

auto close enabled if true

def autoCommit[A](execution: DBSession => A): A

Provides auto-commit session block.

Provides auto-commit session block.

Type Params
A

return type

Value Params
execution

block

Returns

result value

Returns auto-commit session.

Returns auto-commit session.

Returns

session

def autoCommitWithConnection[A](execution: Connection => A): A

Provides auto-commit session block.

Provides auto-commit session block.

Type Params
A

return type

Value Params
execution

block

Returns

result value

def begin(): Unit

Begins a new transaction.

Begins a new transaction.

def beginIfNotYet(): Unit

Begins a new transaction if the other one does not already start.

Begins a new transaction if the other one does not already start.

def close(): Unit

Close the connection.

Close the connection.

def commit(): Unit

Commits the current transaction.

Commits the current transaction.

returns the additional attributes of current JDBC connection.

returns the additional attributes of current JDBC connection.

Returns the current transaction. If the transaction has not started yet, IllegalStateException will be thrown.

Returns the current transaction. If the transaction has not started yet, IllegalStateException will be thrown.

Returns

tx

def describe(table: String): String

Returns describe style string value for the table

Returns describe style string value for the table

Value Params
table

table name (with schema optionally)

Returns

described information

def futureLocalTx[A](execution: DBSession => Future[A])(implicit ec: ExecutionContext): Future[A]

Easy way to checkout the current connection to be used in a transaction that needs to be committed/rolled back depending on Future results.

Easy way to checkout the current connection to be used in a transaction that needs to be committed/rolled back depending on Future results.

Type Params
A

future result type

Value Params
execution

block that takes a session and returns a future

Returns

future result

def getAllColumns(meta: DatabaseMetaData, schema: String, table: String): ResultSet

Returns columns resultset in schema.tableNames

Returns columns resultset in schema.tableNames

Value Params
meta

database meta data

schema

schema name

table

table name

Returns

resultset related to columns

def getColumnNames(tableName: String, tableTypes: Array[String]): List[String]

Returns all the column names on the matched table name

Returns all the column names on the matched table name

def getTable(table: String, tableTypes: Array[String]): Option[Table]

Returns table information if exists

Returns table information if exists

Value Params
table

table name (with schema optionally)

Returns

table information

def getTableNames(tableNamePattern: String, tableTypes: Array[String]): List[String]

Returns all the table information that match the pattern

Returns all the table information that match the pattern

Value Params
tableNamePattern

table name pattern (with schema optionally)

Returns

table information

def isTxAlreadyStarted: Boolean

Returns is the current transaction already started.

Returns is the current transaction already started.

Returns

result

def isTxNotActive: Boolean

Returns is the current transaction is active.

Returns is the current transaction is active.

Returns

result

def isTxNotYetStarted: Boolean

Returns is the current transaction hasn't started yet.

Returns is the current transaction hasn't started yet.

Returns

result

Set isolation level.

Set isolation level.

def localTx[A](execution: DBSession => A)(implicit boundary: TxBoundary[A]): A

Provides local-tx session block.

Provides local-tx session block.

Type Params
A

return type

Value Params
execution

block

Returns

result value

def localTxWithConnection[A](execution: Connection => A)(implicit boundary: TxBoundary[A]): A

Provides local-tx session block.

Provides local-tx session block.

Type Params
A

return type

Value Params
execution

block

Returns

result value

def newTx: Tx

Starts a new transaction and returns it.

Starts a new transaction and returns it.

Returns

tx

def readOnly[A](execution: DBSession => A): A

Provides read-only session block.

Provides read-only session block.

Type Params
A

return type

Value Params
execution

block

Returns

result value

Returns read-only session.

Returns read-only session.

Returns

session

def readOnlyWithConnection[A](execution: Connection => A): A

Provides read-only session block.

Provides read-only session block.

Type Params
A

return type

Value Params
execution

block

Returns

result value

def rollback(): Unit

Rolls back the current transaction.

Rolls back the current transaction.

def rollbackIfActive(): Unit

Rolls back the current transaction if the transaction is still active.

Rolls back the current transaction if the transaction is still active.

def showTables(tableNamePattern: String, tableTypes: Array[String]): String

Returns table name list

Returns table name list

Value Params
tableNamePattern

table name pattern

tableTypes

table types

Returns

table name list

def tx: Tx

Returns the current transaction. If the transaction has not started yet, IllegalStateException will be thrown.

Returns the current transaction. If the transaction has not started yet, IllegalStateException will be thrown.

Returns

tx

def withinTx[A](execution: DBSession => A): A

Provides within-tx session block.

Provides within-tx session block.

Type Params
A

return type

Value Params
execution

block

Returns

result value

Returns within-tx session.

Returns within-tx session.

Returns

session

def withinTxWithConnection[A](execution: Connection => A): A

Provides within-tx session block.

Provides within-tx session block.

Type Params
A

return type

Value Params
execution

block

Returns

result value

Inherited methods

def futureUsing[R <: Closable, A](resource: R)(f: R => Future[A])(implicit ec: ExecutionContext): Future[A]

Guarantees a Closeable resource will be closed after being passed to a block that takes the resource as a parameter and returns a Future.

Guarantees a Closeable resource will be closed after being passed to a block that takes the resource as a parameter and returns a Future.

Inherited from
LoanPattern
def using[R <: Closable, A](resource: R)(f: R => A): A
Inherited from
LoanPattern

Inherited fields

protected val log: Log

Logger

Logger

Inherited from
LogSupport