/** * Returns the default datasource. */ public static DataSource getDataSource() { return getDataSource("default"); }
/** * Returns the default datasource. */ public static DataSource getDataSource() { return getDataSource("default"); }
public static DataSource getDataSource() { return getDataSource(DEFAULT); }
public static Connection getNewConnection(String dbName, boolean autoCommit) throws SQLException { Connection connection = DB.getDataSource(dbName).getConnection(); connection.setAutoCommit(autoCommit); return connection; }
public static Connection getConnection(String name, boolean autocommit) { try { Connection connection = getDataSource(name).getConnection(); connection.setAutoCommit(autocommit); return connection; } catch (Exception e) { // Exception throw new DatabaseException(e.getMessage()); } }
protected Properties properties(String dbName, Configuration dbConfig) { Properties properties = new Properties(); properties.putAll(dbConfig.getProperties()); properties.put("javax.persistence.transaction", "RESOURCE_LOCAL"); properties.put("javax.persistence.provider", "org.hibernate.ejb.HibernatePersistence"); properties.put("hibernate.dialect", getDefaultDialect(dbConfig, dbConfig.getProperty("db.driver"))); if (!dbConfig.getProperty("jpa.ddl", Play.mode.isDev() ? "update" : "none").equals("none")) { properties.setProperty("hibernate.hbm2ddl.auto", dbConfig.getProperty("jpa.ddl", "update")); } properties.put("hibernate.connection.datasource", DB.getDataSource(dbName)); return properties; }
DataSource ds = DB.getDataSource(dbName); if (ds == null || !(ds instanceof ComboPooledDataSource)) { out.println("Datasource:");
public static synchronized void checkEvolutionsState(String dbName) { for (Entry<String, VirtualFile> moduleRoot : modulesWithEvolutions.entrySet()) { if (DB.getDataSource(dbName) != null) { List<Evolution> evolutionScript = getEvolutionScript(dbName, moduleRoot.getKey(), moduleRoot.getValue()); Connection connection = null;
DataSource ds = DB.getDataSource(dbName); if (ds == null || !(ds instanceof HikariDataSource)) { out.println("Datasource:");
Configuration dbConfig = new Configuration(dbName); System.out.println("~ Connected to " + DB.getDataSource(dbName).getConnection().getMetaData().getURL());
/** * Open a connection for the current thread. * * @param name * Name of the DB * @return A valid SQL connection */ public static Connection getConnection(String name) { try { if (JPA.isEnabled()) { return ((SessionImpl) ((HibernateEntityManager) JPA.em(name)).getSession()).connection(); } Connection localConnection = getLocalConnection(name); if (localConnection != null) { return localConnection; } // We have no connection Connection connection = getDataSource(name).getConnection(); registerLocalConnection(name, connection); return connection; } catch (NullPointerException e) { if (getDataSource(name) == null) { throw new DatabaseException("No database found. Check the configuration of your application.", e); } throw e; } catch (Exception e) { // Exception throw new DatabaseException(e.getMessage()); } }
config.loadFromProperties(); try { config.setDataSource(new WrappingDatasource(DB.getDataSource(key))); } catch(Exception e) { throw ebeanConf.reportError(
DataSource ds = DB.getDataSource(dbName);