public class DefaultDatabase extends Database
Constructor and Description |
---|
DefaultDatabase(play.api.db.Database database) |
DefaultDatabase(java.lang.String name,
Configuration configuration)
Create a default BoneCP-backed database.
|
DefaultDatabase(java.lang.String name,
java.util.Map<java.lang.String,? extends java.lang.Object> config)
Create a default BoneCP-backed database.
|
Modifier and Type | Method and Description |
---|---|
java.sql.Connection |
getConnection()
Get a JDBC connection from the underlying data source.
|
java.sql.Connection |
getConnection(boolean autocommit)
Get a JDBC connection from the underlying data source.
|
javax.sql.DataSource |
getDataSource()
The underlying JDBC data source for this database.
|
java.lang.String |
getName()
The configuration name for this database.
|
java.lang.String |
getUrl()
The JDBC connection URL this database, i.e.
|
void |
shutdown()
Shutdown this database, closing the underlying data source.
|
<A> A |
withConnection(boolean autocommit,
ConnectionCallable<A> block)
Execute a block of code, providing a JDBC connection.
|
void |
withConnection(boolean autocommit,
ConnectionRunnable block)
Execute a block of code, providing a JDBC connection.
|
<A> A |
withConnection(ConnectionCallable<A> block)
Execute a block of code, providing a JDBC connection.
|
void |
withConnection(ConnectionRunnable block)
Execute a block of code, providing a JDBC connection.
|
<A> A |
withTransaction(ConnectionCallable<A> block)
Execute a block of code in the scope of a JDBC transaction.
|
void |
withTransaction(ConnectionRunnable block)
Execute a block of code in the scope of a JDBC transaction.
|
createFrom, createFrom, createFrom, createFrom, inMemory, inMemory, inMemory, inMemory, inMemory, inMemory, inMemoryWith, inMemoryWith, inMemoryWith
public DefaultDatabase(play.api.db.Database database)
public DefaultDatabase(java.lang.String name, Configuration configuration)
public DefaultDatabase(java.lang.String name, java.util.Map<java.lang.String,? extends java.lang.Object> config)
public java.lang.String getName()
Database
public javax.sql.DataSource getDataSource()
Database
getDataSource
in class Database
public java.lang.String getUrl()
Database
public java.sql.Connection getConnection()
Database
getConnection
in class Database
public java.sql.Connection getConnection(boolean autocommit)
Database
getConnection
in class Database
autocommit
- determines whether to autocommit the connectionpublic void withConnection(ConnectionRunnable block)
Database
withConnection
in class Database
block
- code to executepublic <A> A withConnection(ConnectionCallable<A> block)
Database
withConnection
in class Database
block
- code to executepublic void withConnection(boolean autocommit, ConnectionRunnable block)
Database
withConnection
in class Database
autocommit
- determines whether to autocommit the connectionblock
- code to executepublic <A> A withConnection(boolean autocommit, ConnectionCallable<A> block)
Database
withConnection
in class Database
autocommit
- determines whether to autocommit the connectionblock
- code to executepublic void withTransaction(ConnectionRunnable block)
Database
withTransaction
in class Database
block
- code to executepublic <A> A withTransaction(ConnectionCallable<A> block)
Database
withTransaction
in class Database
block
- code to execute