| Constructor and Description |
|---|
DefaultDatabase(play.api.db.Database database) |
DefaultDatabase(java.lang.String name,
com.typesafe.config.Config 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() |
java.lang.String |
getName() |
java.lang.String |
getUrl() |
void |
shutdown()
Shutdown this database, closing the underlying data source.
|
play.api.db.Database |
toScala()
Converts the given database to a Scala database
|
<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.
|
public DefaultDatabase(play.api.db.Database database)
public DefaultDatabase(java.lang.String name,
com.typesafe.config.Config configuration)
name - name for the db's underlying datasourceconfiguration - the database's configurationpublic DefaultDatabase(java.lang.String name,
java.util.Map<java.lang.String,? extends java.lang.Object> config)
name - name for the db's underlying datasourceconfig - the db's configurationpublic java.lang.String getName()
public javax.sql.DataSource getDataSource()
getDataSource in interface Databasepublic java.lang.String getUrl()
public java.sql.Connection getConnection()
DatabaseDon't forget to release the connection at some point by calling close().
getConnection in interface Databasepublic java.sql.Connection getConnection(boolean autocommit)
DatabaseDon't forget to release the connection at some point by calling close().
getConnection in interface Databaseautocommit - determines whether to autocommit the connectionpublic void withConnection(ConnectionRunnable block)
DatabasewithConnection in interface Databaseblock - code to executepublic <A> A withConnection(ConnectionCallable<A> block)
DatabasewithConnection in interface DatabaseA - the return value's typeblock - code to executepublic void withConnection(boolean autocommit,
ConnectionRunnable block)
DatabasewithConnection in interface Databaseautocommit - determines whether to autocommit the connectionblock - code to executepublic <A> A withConnection(boolean autocommit,
ConnectionCallable<A> block)
DatabasewithConnection in interface DatabaseA - the return value's typeautocommit - determines whether to autocommit the connectionblock - code to executepublic void withTransaction(ConnectionRunnable block)
DatabasewithTransaction in interface Databaseblock - code to executepublic <A> A withTransaction(ConnectionCallable<A> block)
DatabasewithTransaction in interface DatabaseA - the return value's typeblock - code to executepublic void shutdown()
Database