Package play.db
Class DB
- java.lang.Object
-
- play.db.DB
-
public class DB extends java.lang.ObjectDatabase connection utilities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDB.ExtendedDatasource
-
Field Summary
Fields Modifier and Type Field Description static javax.sql.DataSourcedatasourceDeprecated.Use datasources insteadprotected static java.util.Map<java.lang.String,DB.ExtendedDatasource>datasourcesThe loaded datasource.static java.lang.StringDEFAULTstatic java.lang.StringdestroyMethodDeprecated.Use datasources instead
-
Constructor Summary
Constructors Constructor Description DB()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose()Close all the open connections for the current thread.static voidclose(java.lang.String name)Close an given open connections for the current threadstatic voidcloseAll()Close all the open connections for the current thread.static voiddestroy(java.lang.String name)Destroy the datasourcestatic voiddestroyAll()Destroy all datasourcesstatic voidexecute(java.lang.String SQL)static voidexecute(java.lang.String name, java.lang.String SQL)static java.sql.ConnectiongetConnection()static java.sql.ConnectiongetConnection(java.lang.String name)Open a connection for the current thread.static javax.sql.DataSourcegetDataSource()static javax.sql.DataSourcegetDataSource(java.lang.String name)static java.util.Map<java.lang.String,javax.sql.DataSource>getDataSources()
-
-
-
Field Detail
-
datasources
protected static final java.util.Map<java.lang.String,DB.ExtendedDatasource> datasources
The loaded datasource.- See Also:
DB.ExtendedDatasource
-
datasource
@Deprecated public static javax.sql.DataSource datasource
Deprecated.Use datasources instead- Since:
- 1.3.0
- See Also:
datasources,DB.ExtendedDatasource
-
destroyMethod
@Deprecated public static java.lang.String destroyMethod
Deprecated.Use datasources insteadThe method used to destroy the datasource- Since:
- 1.3.0
- See Also:
datasources,DB.ExtendedDatasource
-
DEFAULT
public static final java.lang.String DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDataSource
@Nullable public static javax.sql.DataSource getDataSource(@Nonnull java.lang.String name)
-
getDataSource
@Nonnull public static javax.sql.DataSource getDataSource()
-
getDataSources
@Nonnull public static java.util.Map<java.lang.String,javax.sql.DataSource> getDataSources()
-
closeAll
public static void closeAll()
Close all the open connections for the current thread.
-
close
public static void close()
Close all the open connections for the current thread.
-
close
public static void close(java.lang.String name)
Close an given open connections for the current thread- Parameters:
name- Name of the DB
-
getConnection
@Nonnull public static java.sql.Connection getConnection(java.lang.String name)
Open a connection for the current thread.- Parameters:
name- Name of the DB- Returns:
- A valid SQL connection
-
getConnection
@Nonnull public static java.sql.Connection getConnection()
-
execute
public static void execute(java.lang.String SQL)
-
execute
public static void execute(java.lang.String name, java.lang.String SQL)
-
destroy
public static void destroy(java.lang.String name)
Destroy the datasource- Parameters:
name- the DB name
-
destroyAll
public static void destroyAll()
Destroy all datasources
-
-