play.db
类 DB

java.lang.Object
  继承者 play.db.DB

public class DB
extends java.lang.Object

Database connection utilities. This class holds reference to all DB configurations. Each configuration has its own instance of DBConfig. dbConfigName corresponds to properties-names in application.conf. The default DBConfig is the one configured using 'db.' in application.conf dbConfigName = 'other' is configured like this: db_other = mem db_other.user = batman This class also preserves backward compatibility by directing static methods to the default DBConfig-instance


构造方法摘要
DB()
           
 
方法摘要
static void close()
          Close all connections opened for the current thread.
static void destroy()
          Destroy the datasources
static boolean execute(java.lang.String SQL)
          Execute an SQL update
static java.sql.ResultSet executeQuery(java.lang.String SQL)
          Execute an SQL query
static java.sql.Connection getConnection()
          Open a connection for the current thread.
static DBConfig getDBConfig()
          The default DBConfig is the one configured using 'db.' in application.conf
static DBConfig getDBConfig(java.lang.String dbConfigName)
          dbConfigName corresponds to properties-names in application.conf.
static DBConfig getDBConfig(java.lang.String dbConfigName, boolean ignoreError)
          dbConfigName corresponds to properties-names in application.conf.
static java.util.Collection<DBConfig> getDBConfigs()
           
protected static java.lang.String getStatus()
           
protected static void setConfigurations(java.util.List<java.lang.String> dbConfigNames)
          Sets the new list of db configurations.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

DB

public DB()
方法详细信息

setConfigurations

protected static void setConfigurations(java.util.List<java.lang.String> dbConfigNames)
Sets the new list of db configurations. Tries to preserve existing config if not changed

参数:
dbConfigNames -

getDBConfig

public static DBConfig getDBConfig()
The default DBConfig is the one configured using 'db.' in application.conf

返回:
the default DBConfig

getDBConfig

public static DBConfig getDBConfig(java.lang.String dbConfigName)
dbConfigName corresponds to properties-names in application.conf. The default dbConfig is named 'play', and is the one configured using 'db.' in application.conf dbConfigName = 'other' is configured like this: db_other = mem db_other.user = batman An exception is thrown if the config is not found

参数:
dbConfigName - name of the config
返回:
a DBConfig specified by name

getDBConfig

public static DBConfig getDBConfig(java.lang.String dbConfigName,
                                   boolean ignoreError)
dbConfigName corresponds to properties-names in application.conf. The default dbConfig is named 'play', and is the one configured using 'db.' in application.conf dbConfigName = 'other' is configured like this: db_other = mem db_other.user = batman An exception is thrown if the config is not found, unless ignoreError == true

参数:
dbConfigName - name of the config
ignoreError - set to true if null should be returned if config is missing
返回:
a DBConfig specified by name

close

public static void close()
Close all connections opened for the current thread.


getConnection

public static java.sql.Connection getConnection()
Open a connection for the current thread.

返回:
A valid SQL connection

execute

public static boolean execute(java.lang.String SQL)
Execute an SQL update

参数:
SQL -
返回:
false if update failed

executeQuery

public static java.sql.ResultSet executeQuery(java.lang.String SQL)
Execute an SQL query

参数:
SQL -
返回:
The query resultSet

destroy

public static void destroy()
Destroy the datasources


getStatus

protected static java.lang.String getStatus()
返回:
status string for all configured dbConfigs

getDBConfigs

public static java.util.Collection<DBConfig> getDBConfigs()


Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly