Package play.db

Class Databases


  • public final class Databases
    extends Object
    Creation helpers for manually instantiating databases.
    • Method Detail

      • createFrom

        public static Database createFrom​(String name,
                                          String driver,
                                          String url,
                                          Map<String,​? extends Object> config)
        Create a pooled database with the given configuration.
        Parameters:
        name - the database name
        driver - the database driver class
        url - the database url
        config - a map of extra database configuration
        Returns:
        a configured database
      • createFrom

        public static Database createFrom​(String name,
                                          String driver,
                                          String url)
        Create a pooled database with the given configuration.
        Parameters:
        name - the database name
        driver - the database driver class
        url - the database url
        Returns:
        a configured database
      • createFrom

        public static Database createFrom​(String driver,
                                          String url,
                                          Map<String,​? extends Object> config)
        Create a pooled database named "default" with the given configuration.
        Parameters:
        driver - the database driver class
        url - the database url
        config - a map of extra database configuration
        Returns:
        a configured database
      • createFrom

        public static Database createFrom​(String driver,
                                          String url)
        Create a pooled database named "default" with the given driver and url.
        Parameters:
        driver - the database driver class
        url - the database url
        Returns:
        a configured database
      • inMemory

        public static Database inMemory​(String name,
                                        String url,
                                        Map<String,​? extends Object> config)
        Create an in-memory H2 database.
        Parameters:
        name - the database name
        url - the database url
        config - a map of extra database configuration
        Returns:
        a configured in-memory h2 database
      • inMemory

        public static Database inMemory​(String name,
                                        Map<String,​String> urlOptions,
                                        Map<String,​? extends Object> config)
        Create an in-memory H2 database.
        Parameters:
        name - the database name
        urlOptions - a map of extra url options
        config - a map of extra database configuration
        Returns:
        a configured in-memory h2 database
      • inMemory

        public static Database inMemory​(String name,
                                        Map<String,​? extends Object> config)
        Create an in-memory H2 database.
        Parameters:
        name - the database name
        config - a map of extra database configuration
        Returns:
        a configured in-memory h2 database
      • inMemory

        public static Database inMemory​(String name)
        Create an in-memory H2 database.
        Parameters:
        name - the database name
        Returns:
        a configured in-memory h2 database
      • inMemory

        public static Database inMemory​(Map<String,​? extends Object> config)
        Create an in-memory H2 database with name "default".
        Parameters:
        config - a map of extra database configuration
        Returns:
        a configured in-memory h2 database
      • inMemory

        public static Database inMemory()
        Create an in-memory H2 database with name "default".
        Returns:
        a configured in-memory h2 database
      • inMemoryWith

        public static Database inMemoryWith​(String k1,
                                            Object v1)
        Create an in-memory H2 database with name "default" and with extra configuration provided by the given entries.
        Parameters:
        k1 - an H2 configuration key.
        v1 - configuration value corresponding to `k1`
        Returns:
        a configured in-memory H2 database
      • inMemoryWith

        public static Database inMemoryWith​(String k1,
                                            Object v1,
                                            String k2,
                                            Object v2)
        Create an in-memory H2 database with name "default" and with extra configuration provided by the given entries.
        Parameters:
        k1 - an H2 configuration key
        v1 - H2 configuration value corresponding to `k1`
        k2 - a second H2 configuration key
        v2 - a configuration value corresponding to `k2`
        Returns:
        a configured in-memory H2 database
      • inMemoryWith

        public static Database inMemoryWith​(String k1,
                                            Object v1,
                                            String k2,
                                            Object v2,
                                            String k3,
                                            Object v3)
        Create an in-memory H2 database with name "default" and with extra configuration provided by the given entries.
        Parameters:
        k1 - an H2 configuration key
        v1 - H2 configuration value corresponding to `k1`
        k2 - a second H2 configuration key
        v2 - a configuration value corresponding to `k2`
        k3 - a third H2 configuration key
        v3 - a configuration value corresponding to `k3`
        Returns:
        a configured in-memory H2 database