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()Destroy the datasourcestatic voiddestroy(java.lang.String name)Destroy the datasourcestatic voiddestroyAll()Destroy all datasourcesstatic booleanexecute(java.lang.String SQL)Execute an SQL updatestatic booleanexecute(java.lang.String name, java.lang.String SQL)Execute an SQL updatestatic javax.sql.RowSetexecuteQuery(java.lang.String SQL)Execute an SQL querystatic javax.sql.RowSetexecuteQuery(java.lang.String name, java.lang.String SQL)Execute an SQL querystatic java.sql.ConnectiongetConnection()static java.sql.ConnectiongetConnection(java.lang.String name)Open a connection for the current thread.static java.sql.ConnectiongetConnection(java.lang.String name, boolean autocommit)static javax.sql.DataSourcegetDataSource()static javax.sql.DataSourcegetDataSource(java.lang.String name)static voidsafeCloseResultSet(java.sql.ResultSet resultSet)static voidsafeCloseStatement(java.sql.Statement statement)
-
-
-
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
public static javax.sql.DataSource getDataSource(java.lang.String name)
-
getDataSource
public static javax.sql.DataSource getDataSource()
-
getConnection
public static java.sql.Connection getConnection(java.lang.String name, boolean autocommit)
-
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
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
public static java.sql.Connection getConnection()
-
execute
public static boolean execute(java.lang.String name, java.lang.String SQL)Execute an SQL update- Parameters:
name- the DB nameSQL- the SQL statement- Returns:
- true if the next result is a ResultSet object; false if it is an update count or there are no more results
-
execute
public static boolean execute(java.lang.String SQL)
Execute an SQL update- Parameters:
SQL- the SQL statement- Returns:
- true if the next result is a ResultSet object; false if it is an update count or there are no more results
-
executeQuery
public static javax.sql.RowSet executeQuery(java.lang.String SQL)
Execute an SQL query- Parameters:
SQL- the SQL statement- Returns:
- The ResultSet object; false if it is an update count or there are no more results
-
executeQuery
public static javax.sql.RowSet executeQuery(java.lang.String name, java.lang.String SQL)Execute an SQL query- Parameters:
name- the DB nameSQL- the SQL statement- Returns:
- The rowSet of the query
-
safeCloseResultSet
public static void safeCloseResultSet(java.sql.ResultSet resultSet)
-
safeCloseStatement
public static void safeCloseStatement(java.sql.Statement statement)
-
destroy
public static void destroy(java.lang.String name)
Destroy the datasource- Parameters:
name- the DB name
-
destroy
public static void destroy()
Destroy the datasource
-
destroyAll
public static void destroyAll()
Destroy all datasources
-
-