Constructor and Description |
---|
DefaultDatabase(play.api.db.Database database) |
DefaultDatabase(String name,
com.typesafe.config.Config configuration)
Create a default HikariCP-backed database.
|
DefaultDatabase(String name,
Map<String,? extends Object> config)
Create a default HikariCP-backed database.
|
Modifier and Type | Method and Description |
---|---|
Connection |
getConnection()
Get a JDBC connection from the underlying data source.
|
Connection |
getConnection(boolean autocommit)
Get a JDBC connection from the underlying data source.
|
DataSource |
getDataSource() |
String |
getName() |
String |
getUrl() |
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.
|
<A> A |
withTransaction(TransactionIsolationLevel isolationLevel,
ConnectionCallable<A> block)
Execute a block of code in the scope of a JDBC transaction.
|
void |
withTransaction(TransactionIsolationLevel isolationLevel,
ConnectionRunnable block)
Execute a block of code in the scope of a JDBC transaction.
|
public DefaultDatabase(play.api.db.Database database)
public DefaultDatabase(String name, com.typesafe.config.Config configuration)
name
- name for the db's underlying datasourceconfiguration
- the database's configurationpublic String getName()
public DataSource getDataSource()
getDataSource
in interface Database
public String getUrl()
public Connection getConnection()
Database
Don't forget to release the connection at some point by calling close().
getConnection
in interface Database
public Connection getConnection(boolean autocommit)
Database
Don't forget to release the connection at some point by calling close().
getConnection
in interface Database
autocommit
- determines whether to autocommit the connectionpublic void withConnection(ConnectionRunnable block)
Database
withConnection
in interface Database
block
- code to executepublic <A> A withConnection(ConnectionCallable<A> block)
Database
withConnection
in interface Database
A
- the return value's typeblock
- code to executepublic void withConnection(boolean autocommit, ConnectionRunnable block)
Database
withConnection
in interface Database
autocommit
- determines whether to autocommit the connectionblock
- code to executepublic <A> A withConnection(boolean autocommit, ConnectionCallable<A> block)
Database
withConnection
in interface Database
A
- the return value's typeautocommit
- determines whether to autocommit the connectionblock
- code to executepublic void withTransaction(ConnectionRunnable block)
Database
withTransaction
in interface Database
block
- code to executepublic void withTransaction(TransactionIsolationLevel isolationLevel, ConnectionRunnable block)
Database
withTransaction
in interface Database
isolationLevel
- determines transaction isolation levelblock
- code to executepublic <A> A withTransaction(ConnectionCallable<A> block)
Database
withTransaction
in interface Database
A
- the return value's typeblock
- code to executepublic <A> A withTransaction(TransactionIsolationLevel isolationLevel, ConnectionCallable<A> block)
Database
withTransaction
in interface Database
A
- the return value's typeisolationLevel
- determines transaction isolation levelblock
- code to execute