case class NamedDB(name: Any, settingsProvider: SettingsProvider = SettingsProvider.default)(implicit context: ConnectionPoolContext = NoConnectionPoolContext) extends DBConnection with Product with Serializable
Named Basic DB Accessor
It's easier to use named ConnectionPool with this class.
ConnectionPool.add('named, "jdbc:...", "user", "password") val users = NamedDB('named) readOnly { session => session.list("select * from user") }
Please note that a single NamedDB instance should be used only once, as the connection is closed after being used. To re-use an instance, use the .setAutoClose(false) method.
- Source
- NamedDB.scala
- Alphabetic
- By Inheritance
- NamedDB
- Serializable
- Serializable
- Product
- Equals
- DBConnection
- AutoCloseable
- LoanPattern
- LogSupport
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new NamedDB(name: Any, settingsProvider: SettingsProvider = SettingsProvider.default)(implicit context: ConnectionPoolContext = NoConnectionPoolContext)
Type Members
-
type
Closable = AnyRef { def close(): Unit }
- Definition Classes
- LoanPattern
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
autoClose(autoClose: Boolean): DBConnection
Switches auto close mode.
-
def
autoCommit[A](execution: (DBSession) ⇒ A): A
Provides auto-commit session block.
Provides auto-commit session block.
- A
return type
- execution
block
- returns
result value
- Definition Classes
- DBConnection
-
def
autoCommitSession(settings: SettingsProvider = SettingsProvider.default): DBSession
Returns auto-commit session.
-
def
autoCommitWithConnection[A](execution: (Connection) ⇒ A): A
Provides auto-commit session block.
Provides auto-commit session block.
- A
return type
- execution
block
- returns
result value
- Definition Classes
- DBConnection
-
def
begin(): Unit
Begins a new transaction.
Begins a new transaction.
- Definition Classes
- DBConnection
-
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.
- Definition Classes
- DBConnection
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
close(): Unit
Close the connection.
Close the connection.
- Definition Classes
- DBConnection → AutoCloseable
-
def
commit(): Unit
Commits the current transaction.
Commits the current transaction.
- Definition Classes
- DBConnection
-
def
conn: Connection
Returns current JDBC connection.
Returns current JDBC connection.
- Definition Classes
- NamedDB → DBConnection
-
def
connectionAttributes: DBConnectionAttributes
returns the additional attributes of current JDBC connection.
returns the additional attributes of current JDBC connection.
- Definition Classes
- NamedDB → DBConnection
-
def
currentTx: Tx
Returns the current transaction.
Returns the current transaction. If the transaction has not started yet, IllegalStateException will be thrown.
- returns
tx
- Definition Classes
- DBConnection
-
def
describe(table: String): String
Returns describe style string value for the table
Returns describe style string value for the table
- table
table name (with schema optionally)
- returns
described information
- Definition Classes
- DBConnection
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
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.
- A
future result type
- execution
block that takes a session and returns a future
- returns
future result
- Definition Classes
- DBConnection
-
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.
- Definition Classes
- LoanPattern
-
def
getAllColumns(meta: DatabaseMetaData, schema: String, table: String): ResultSet
Returns columns resultset in schema.tableNames
Returns columns resultset in schema.tableNames
- meta
database meta data
- schema
schema name
- table
table name
- returns
resultset related to columns
- Definition Classes
- DBConnection
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
getColumnNames(tableName: String, tableTypes: Array[String] = DBConnection.tableTypes): List[String]
Returns all the column names on the matched table name
Returns all the column names on the matched table name
- Definition Classes
- DBConnection
-
def
getTable(table: String, tableTypes: Array[String] = DBConnection.tableTypes): Option[Table]
Returns table information if exists
Returns table information if exists
- table
table name (with schema optionally)
- returns
table information
- Definition Classes
- DBConnection
-
def
getTableNames(tableNamePattern: String = "%", tableTypes: Array[String] = DBConnection.tableTypes): List[String]
Returns all the table information that match the pattern
Returns all the table information that match the pattern
- tableNamePattern
table name pattern (with schema optionally)
- returns
table information
- Definition Classes
- DBConnection
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isTxAlreadyStarted: Boolean
Returns is the current transaction already started.
-
def
isTxNotActive: Boolean
Returns is the current transaction is active.
-
def
isTxNotYetStarted: Boolean
Returns is the current transaction hasn't started yet.
-
def
isolationLevel(isolationLevel: IsolationLevel): DBConnection
Set isolation level.
Set isolation level.
- Definition Classes
- DBConnection
-
def
localTx[A](execution: (DBSession) ⇒ A)(implicit boundary: TxBoundary[A] = defaultTxBoundary[A]): A
Provides local-tx session block.
Provides local-tx session block.
- A
return type
- execution
block
- returns
result value
- Definition Classes
- DBConnection
-
def
localTxWithConnection[A](execution: (Connection) ⇒ A)(implicit boundary: TxBoundary[A] = defaultTxBoundary[A]): A
Provides local-tx session block.
Provides local-tx session block.
- A
return type
- execution
block
- returns
result value
- Definition Classes
- DBConnection
-
val
log: Log
Logger
Logger
- Attributes
- protected
- Definition Classes
- LogSupport
- val name: Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
newTx: Tx
Starts a new transaction and returns it.
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
readOnly[A](execution: (DBSession) ⇒ A): A
Provides read-only session block.
Provides read-only session block.
- A
return type
- execution
block
- returns
result value
- Definition Classes
- DBConnection
-
def
readOnlySession(settings: SettingsProvider = SettingsProvider.default): DBSession
Returns read-only session.
-
def
readOnlyWithConnection[A](execution: (Connection) ⇒ A): A
Provides read-only session block.
Provides read-only session block.
- A
return type
- execution
block
- returns
result value
- Definition Classes
- DBConnection
-
def
rollback(): Unit
Rolls back the current transaction.
Rolls back the current transaction.
- Definition Classes
- DBConnection
-
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.
- Definition Classes
- DBConnection
-
val
settingsProvider: SettingsProvider
- Definition Classes
- NamedDB → DBConnection
-
def
showTables(tableNamePattern: String = "%", tableTypes: Array[String] = DBConnection.tableTypes): String
Returns table name list
Returns table name list
- tableNamePattern
table name pattern
- tableTypes
table types
- returns
table name list
- Definition Classes
- DBConnection
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- def toDB(): DB
-
def
tx: Tx
Returns the current transaction.
Returns the current transaction. If the transaction has not started yet, IllegalStateException will be thrown.
- returns
tx
- Definition Classes
- DBConnection
-
def
using[R <: Closable, A](resource: R)(f: (R) ⇒ A): A
- Definition Classes
- LoanPattern
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
withinTx[A](execution: (DBSession) ⇒ A): A
Provides within-tx session block.
Provides within-tx session block.
- A
return type
- execution
block
- returns
result value
- Definition Classes
- DBConnection
-
def
withinTxSession(tx: Tx = currentTx, settings: SettingsProvider = SettingsProvider.default): DBSession
Returns within-tx session.
-
def
withinTxWithConnection[A](execution: (Connection) ⇒ A): A
Provides within-tx session block.
Provides within-tx session block.
- A
return type
- execution
block
- returns
result value
- Definition Classes
- DBConnection