play.db

## Class DB

- java.lang.Object
- - play.db.DB

-     public class DB
      extends java.lang.Object

  Database connection utilities.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DB.ExtendedDatasource`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static javax.sql.DataSource` | `datasource` Deprecated. Use datasources instead
    `protected static java.util.Map<java.lang.String,DB.ExtendedDatasource>` | `datasources` The loaded datasource.
    `static java.lang.String` | `DEFAULT`
    `static java.lang.String` | `destroyMethod` Deprecated. Use datasources instead

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DB()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `close()` Close all the open connections for the current thread.
    `static void` | `close(java.lang.String name)` Close an given open connections for the current thread
    `static void` | `closeAll()` Close all the open connections for the current thread.
    `static void` | `destroy()` Destroy the datasource
    `static void` | `destroy(java.lang.String name)` Destroy the datasource
    `static void` | `destroyAll()` Destroy all datasources
    `static boolean` | `execute(java.lang.String SQL)` Execute an SQL update
    `static boolean` | `execute(java.lang.String name, java.lang.String SQL)` Execute an SQL update
    `static javax.sql.RowSet` | `executeQuery(java.lang.String SQL)` Execute an SQL query
    `static javax.sql.RowSet` | `executeQuery(java.lang.String name, java.lang.String SQL)` Execute an SQL query
    `static java.sql.Connection` | `getConnection()`
    `static java.sql.Connection` | `getConnection(java.lang.String name)` Open a connection for the current thread.
    `static java.sql.Connection` | `getConnection(java.lang.String name, boolean autocommit)`
    `static javax.sql.DataSource` | `getDataSource()`
    `static javax.sql.DataSource` | `getDataSource(java.lang.String name)`
    `static void` | `safeCloseResultSet(java.sql.ResultSet resultSet)`
    `static void` | `safeCloseStatement(java.sql.Statement statement)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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 instead
      The 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

  - ### Constructor Detail

    - #### DB

          public DB()

  - ### 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 name
        `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

    - #### 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 name
        `SQL` - 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

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