/** * @return all databases associated with the {@link #dbApi()}. * * @see DBApi#getDatabases() */ default List<Database> databases() { return dbApi().getDatabases(); }
/** * @return the database with the given name, associated with the {@link #dbApi()}. * * @param name the database name * @see DBApi#getDatabase(String) */ default Database database(String name) { return dbApi().getDatabase(name); }
public static synchronized void checkEvolutionsState() { // Look over all the DB Set<String> dBNames = Configuration.getDbNames(); for (String dbName : dBNames) { checkEvolutionsState(dbName); } }
/** * Returns a connection from the default datasource, * with auto-commit enabled. */ public static Connection getConnection() { return getConnection("default"); }
/** * Returns the default datasource. */ public static DataSource getDataSource() { return getDataSource("default"); }
/** * Create an in-memory H2 database. * * @param name the database name * @param url the database url * @param config a map of extra database configuration * @return a configured in-memory h2 database */ public static Database inMemory(String name, String url, Map<String, ? extends Object> config) { return createFrom(name, "org.h2.Driver", url, config); }
/** * Create an in-memory H2 database with name "default". * * @param config a map of extra database configuration * @return a configured in-memory h2 database */ public static Database inMemory(Map<String, ? extends Object> config) { return inMemory("default", config); }
public static synchronized boolean applyScript(boolean runScript, String moduleKey, VirtualFile evolutionsDirectory) { // Look over all the DB Set<String> dBNames = Configuration.getDbNames(); for (String dbName : dBNames) { return applyScript(dbName, runScript, moduleKey, evolutionsDirectory); } return true; }
/** * Executes a block of code, providing a JDBC connection. * The connection and all created statements are automatically released. * * @param autocommit Auto-commit setting * @param block Code block to execute * @param application Play application (<tt>play.api.Play.unsafeApplication()</tt>) */ public static <A> A withConnection(boolean autocommit, ConnectionCallable<A> block, Application application) { return withConnection("default", autocommit, block, application); }
/** * Destroy the datasource */ public static void destroy() { destroy(DEFAULT); }
/** * Execute an SQL update * * @param SQL * the SQL statement * @return true if the next result is a ResultSet object; false if it is an update count or there are no more * results */ public static boolean execute(String SQL) { return execute(DEFAULT, SQL); }
/** * Execute a block of code, in the scope of a JDBC transaction. * The connection and all created statements are automatically released. * The transaction is automatically committed, unless an exception occurs. * * @param block Code block to execute * @param application Play application (<tt>play.api.Play.unsafeApplication()</tt>) */ public static void withTransaction(ConnectionRunnable block, Application application) { withTransaction("default", block, application); }
/** * Close all the open connections for the current thread. */ public static void close() { close(DEFAULT); }
/** * Execute an SQL query * * @param SQL * the SQL statement * @return The ResultSet object; false if it is an update count or there are no more results */ public static RowSet executeQuery(String SQL) { return executeQuery(DEFAULT, SQL); }
/** * Returns a connection from the default datasource, * with the specified auto-commit setting. */ public static Connection getConnection(boolean autocommit) { return getConnection("default", autocommit); }
/** * Create a pooled database named "default" with the given configuration. * * @param driver the database driver class * @param url the database url * @param config a map of extra database configuration * @return a configured database */ public static Database createFrom(String driver, String url, Map<String, ? extends Object> config) { return createFrom("default", driver, url, config); }
/** * Create an in-memory H2 database. * * @param name the database name * @param config a map of extra database configuration * @return a configured in-memory h2 database */ public static Database inMemory(String name, Map<String, ? extends Object> config) { return inMemory(name, "jdbc:h2:mem:" + name, config); }
/** * Execute a block of code, providing a JDBC connection. * The connection and all created statements are automatically released. * * @param block Code block to execute */ public static <A> A withConnection(ConnectionCallable<A> block) { return withConnection("default", true, block); }
/** * Returns a connection from any datasource, with auto-commit enabled. * * @param name Datasource name */ public static Connection getConnection(String name) { return getConnection(name, true); }
/** * Returns a connection from the default datasource, with the specified auto-commit setting. */ public static Connection getConnection(boolean autocommit) { return getConnection("default", autocommit); }