Package play.db

Class DB


  • public class DB
    extends java.lang.Object
    Database connection utilities.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DB.ExtendedDatasource  
    • Field Summary

      Fields 
      Modifier and Type Field 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 Description
      DB()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method 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​(java.lang.String name)
      Destroy the datasource
      static void destroyAll()
      Destroy all datasources
      static void execute​(java.lang.String SQL)  
      static void execute​(java.lang.String name, java.lang.String SQL)  
      static java.sql.Connection getConnection()  
      static java.sql.Connection getConnection​(java.lang.String name)
      Open a connection for the current thread.
      static javax.sql.DataSource getDataSource()  
      static javax.sql.DataSource getDataSource​(java.lang.String name)  
      static java.util.Map<java.lang.String,​javax.sql.DataSource> getDataSources()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DB

        public DB()
    • 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