public class DB
extends java.lang.Object
Constructor and Description |
---|
DB() |
Modifier and Type | Method and Description |
---|---|
static <A> scala.runtime.AbstractFunction1<java.sql.Connection,A> |
connectionFunction(ConnectionCallable<A> block)
Create a Scala function wrapper for ConnectionCallable.
|
static scala.runtime.AbstractFunction1<java.sql.Connection,scala.runtime.BoxedUnit> |
connectionFunction(ConnectionRunnable block)
Create a Scala function wrapper for ConnectionRunnable.
|
static java.sql.Connection |
getConnection()
Returns a connection from the default datasource,
with auto-commit enabled.
|
static java.sql.Connection |
getConnection(boolean autocommit)
Returns a connection from the default datasource,
with the specified auto-commit setting.
|
static java.sql.Connection |
getConnection(java.lang.String name)
Returns a connection from any datasource, with auto-commit enabled.
|
static java.sql.Connection |
getConnection(java.lang.String name,
boolean autocommit)
Get a connection from any datasource,
with the specified auto-commit setting.
|
static javax.sql.DataSource |
getDataSource()
Returns the default datasource.
|
static javax.sql.DataSource |
getDataSource(java.lang.String name)
Returns specified database.
|
static <A> A |
withConnection(boolean autocommit,
ConnectionCallable<A> block)
Executes a block of code, providing a JDBC connection.
|
static <A> A |
withConnection(boolean autocommit,
ConnectionCallable<A> block,
play.api.Application application)
Executes a block of code, providing a JDBC connection.
|
static void |
withConnection(boolean autocommit,
ConnectionRunnable block)
Executes a block of code, providing a JDBC connection.
|
static void |
withConnection(boolean autocommit,
ConnectionRunnable block,
play.api.Application application)
Executes a block of code, providing a JDBC connection.
|
static <A> A |
withConnection(ConnectionCallable<A> block)
Execute a block of code, providing a JDBC connection.
|
static <A> A |
withConnection(ConnectionCallable<A> block,
play.api.Application application)
Execute a block of code, providing a JDBC connection.
|
static void |
withConnection(ConnectionRunnable block)
Execute a block of code, providing a JDBC connection.
|
static void |
withConnection(ConnectionRunnable block,
play.api.Application application)
Execute a block of code, providing a JDBC connection.
|
static <A> A |
withConnection(java.lang.String name,
boolean autocommit,
ConnectionCallable<A> block)
Executes a block of code, providing a JDBC connection.
|
static <A> A |
withConnection(java.lang.String name,
boolean autocommit,
ConnectionCallable<A> block,
play.api.Application application)
Executes a block of code, providing a JDBC connection.
|
static void |
withConnection(java.lang.String name,
boolean autocommit,
ConnectionRunnable block)
Executes a block of code, providing a JDBC connection.
|
static void |
withConnection(java.lang.String name,
boolean autocommit,
ConnectionRunnable block,
play.api.Application application)
Executes a block of code, providing a JDBC connection.
|
static <A> A |
withConnection(java.lang.String name,
ConnectionCallable<A> block)
Executes a block of code, providing a JDBC connection.
|
static <A> A |
withConnection(java.lang.String name,
ConnectionCallable<A> block,
play.api.Application application)
Executes a block of code, providing a JDBC connection.
|
static void |
withConnection(java.lang.String name,
ConnectionRunnable block)
Executes a block of code, providing a JDBC connection.
|
static void |
withConnection(java.lang.String name,
ConnectionRunnable block,
play.api.Application application)
Executes a block of code, providing a JDBC connection.
|
static <A> A |
withTransaction(ConnectionCallable<A> block)
Execute a block of code, in the scope of a JDBC transaction.
|
static <A> A |
withTransaction(ConnectionCallable<A> block,
play.api.Application application)
Execute a block of code, in the scope of a JDBC transaction.
|
static void |
withTransaction(ConnectionRunnable block)
Execute a block of code, in the scope of a JDBC transaction.
|
static void |
withTransaction(ConnectionRunnable block,
play.api.Application application)
Execute a block of code, in the scope of a JDBC transaction.
|
static <A> A |
withTransaction(java.lang.String name,
ConnectionCallable<A> block)
Execute a block of code, in the scope of a JDBC transaction.
|
static <A> A |
withTransaction(java.lang.String name,
ConnectionCallable<A> block,
play.api.Application application)
Execute a block of code, in the scope of a JDBC transaction.
|
static void |
withTransaction(java.lang.String name,
ConnectionRunnable block)
Execute a block of code, in the scope of a JDBC transaction.
|
static void |
withTransaction(java.lang.String name,
ConnectionRunnable block,
play.api.Application application)
Execute a block of code, in the scope of a JDBC transaction.
|
public static javax.sql.DataSource getDataSource()
public static javax.sql.DataSource getDataSource(java.lang.String name)
name
- Datasource namepublic static java.sql.Connection getConnection()
public static java.sql.Connection getConnection(boolean autocommit)
public static java.sql.Connection getConnection(java.lang.String name)
name
- Datasource namepublic static java.sql.Connection getConnection(java.lang.String name, boolean autocommit)
name
- Datasource nameautocommit
- Auto-commit settingpublic static void withConnection(java.lang.String name, boolean autocommit, ConnectionRunnable block, play.api.Application application)
name
- Datasource nameautocommit
- Auto-commit settingblock
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static void withConnection(java.lang.String name, ConnectionRunnable block, play.api.Application application)
name
- Datasource nameblock
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static void withConnection(boolean autocommit, ConnectionRunnable block, play.api.Application application)
autocommit
- Auto-commit settingblock
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static void withConnection(ConnectionRunnable block, play.api.Application application)
block
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static void withConnection(java.lang.String name, boolean autocommit, ConnectionRunnable block)
name
- Datasource nameautocommit
- Auto-commit settingblock
- Code block to executepublic static void withConnection(java.lang.String name, ConnectionRunnable block)
name
- Datasource nameblock
- Code block to executepublic static void withConnection(boolean autocommit, ConnectionRunnable block)
autocommit
- Auto-commit settingblock
- Code block to executepublic static void withConnection(ConnectionRunnable block)
block
- Code block to executepublic static <A> A withConnection(java.lang.String name, boolean autocommit, ConnectionCallable<A> block, play.api.Application application)
name
- Datasource nameautocommit
- Auto-commit settingblock
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static <A> A withConnection(java.lang.String name, ConnectionCallable<A> block, play.api.Application application)
name
- Datasource nameblock
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static <A> A withConnection(boolean autocommit, ConnectionCallable<A> block, play.api.Application application)
autocommit
- Auto-commit settingblock
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static <A> A withConnection(ConnectionCallable<A> block, play.api.Application application)
block
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static <A> A withConnection(java.lang.String name, boolean autocommit, ConnectionCallable<A> block)
name
- Datasource nameautocommit
- Auto-commit settingblock
- Code block to executepublic static <A> A withConnection(java.lang.String name, ConnectionCallable<A> block)
name
- Datasource nameblock
- Code block to executepublic static <A> A withConnection(boolean autocommit, ConnectionCallable<A> block)
autocommit
- Auto-commit settingblock
- Code block to executepublic static <A> A withConnection(ConnectionCallable<A> block)
block
- Code block to executepublic static void withTransaction(java.lang.String name, ConnectionRunnable block, play.api.Application application)
name
- Datasource nameblock
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static void withTransaction(ConnectionRunnable block, play.api.Application application)
block
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static void withTransaction(java.lang.String name, ConnectionRunnable block)
name
- Datasource nameblock
- Code block to executepublic static void withTransaction(ConnectionRunnable block)
block
- Code block to executepublic static <A> A withTransaction(java.lang.String name, ConnectionCallable<A> block, play.api.Application application)
name
- Datasource nameblock
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static <A> A withTransaction(ConnectionCallable<A> block, play.api.Application application)
block
- Code block to executeapplication
- Play application (play.api.Play.unsafeApplication())public static <A> A withTransaction(java.lang.String name, ConnectionCallable<A> block)
name
- Datasource nameblock
- Code block to executepublic static <A> A withTransaction(ConnectionCallable<A> block)
block
- Code block to executepublic static final scala.runtime.AbstractFunction1<java.sql.Connection,scala.runtime.BoxedUnit> connectionFunction(ConnectionRunnable block)
public static final <A> scala.runtime.AbstractFunction1<java.sql.Connection,A> connectionFunction(ConnectionCallable<A> block)