Package com.avaje.ebean.config

Examples of com.avaje.ebean.config.DataSourceConfig


  }

  public static void main(String[] args) {
    // ### Configuration Objects ###
    ServerConfig serverConfig = new ServerConfig();
    DataSourceConfig dataSourceConfig = new DataSourceConfig();

    // ### Configuration Settings ###
    // -> data source
    dataSourceConfig.setDriver("org.h2.Driver");
    dataSourceConfig.setUsername("howtouser");
    dataSourceConfig.setPassword("");
    dataSourceConfig.setUrl("jdbc:h2:db/howto1");

    // -> server
    serverConfig.setName("default");
    serverConfig.setDataSourceConfig(dataSourceConfig);
View Full Code Here


    ServerConfig c = new ServerConfig();
    c.setName("ora");

    // requires oracle driver in class path
    DataSourceConfig oraDb = new DataSourceConfig();
    oraDb.setDriver("oracle.jdbc.driver.OracleDriver");
    oraDb.setUsername("junk");
    oraDb.setPassword("junk");
    oraDb.setUrl("jdbc:oracle:thin:junk/junk@localhost:1521:XE");
    oraDb.setHeartbeatSql("select count(*) from dual");
   
   
    c.loadFromProperties();
    c.setDdlGenerate(true);
    c.setDdlRun(true);
View Full Code Here

    ServerConfig c = new ServerConfig();
    c.setName("pgtest");

    // requires postgres driver in class path
    DataSourceConfig postgresDb = new DataSourceConfig();
    postgresDb.setDriver("org.postgresql.Driver");
    postgresDb.setUsername("test");
    postgresDb.setPassword("test");
    postgresDb.setUrl("jdbc:postgresql://127.0.0.1:5432/test");
    postgresDb.setHeartbeatSql("select count(*) from t_one");
   
    c.loadFromProperties();
    c.setDdlGenerate(true);
    c.setDdlRun(true);
    c.setDefaultServer(false);
View Full Code Here

      return;
    }
   
    String name = "mysql";

    DataSourceConfig dsConfig = new DataSourceConfig();
    dsConfig.loadSettings(name);
    dsConfig.setMinConnections(2);
    dsConfig.setMaxConnections(25);
    dsConfig.setWaitTimeoutMillis(30000);
    dsConfig.setCaptureStackTrace(true);

    DataSourcePool pool = new DataSourcePool(null, name, dsConfig);

   
    //pool.checkDataSource();
View Full Code Here

      } else {
        return ds;
      }
    }

    DataSourceConfig dsConfig = config.getDataSourceConfig();
    if (dsConfig == null) {
      String m = "No DataSourceConfig definded for " + config.getName();
      throw new PersistenceException(m);
    }

    if (dsConfig.isOffline()) {
      if (config.getDatabasePlatformName() == null) {
        String m = "You MUST specify a DatabasePlatformName on ServerConfig when offline";
        throw new PersistenceException(m);
      }
      return null;
View Full Code Here

            db.setRegister(false);
            db.setClasses(getDatabaseClasses());
            db.setName(description.getName());
            server.configureDbConfig(db);

            DataSourceConfig ds = db.getDataSourceConfig();

            ds.setUrl(replaceDatabaseString(ds.getUrl()));
            dataFolder.mkdirs();

            ClassLoader previous = Thread.currentThread().getContextClassLoader();

            Thread.currentThread().setContextClassLoader(classLoader);
View Full Code Here

        }
    }

    private void prepareDatabase(String driver, String url, String username, String password, String isolation) {
        //Setup the data source
        DataSourceConfig ds = new DataSourceConfig();
        ds.setDriver(driver);
        ds.setUrl(replaceDatabaseString(url));
        ds.setUsername(username);
        ds.setPassword(password);
        ds.setIsolationLevel(TransactionIsolation.getLevel(isolation));

        //Setup the server configuration
        ServerConfig sc = new ServerConfig();
        sc.setDefaultServer(false);
        sc.setRegister(false);
        sc.setName(ds.getUrl().replaceAll("[^a-zA-Z0-9]", ""));

        //Get all persistent classes
        List<Class<?>> classes = getDatabaseClasses();

        //Do a sanity check first
        if (classes.isEmpty()) {
            //Exception: There is no use in continuing to load this database
            throw new RuntimeException("Database has been enabled, but no classes are registered to it");
        }

        //Register them with the EbeanServer
        sc.setClasses(classes);

        //Check if the SQLite JDBC supplied with Bukkit is being used
        if (ds.getDriver().equalsIgnoreCase("org.sqlite.JDBC")) {
            //Remember the database is a SQLite-database
            usingSQLite = true;

            //Modify the platform, as SQLite has no AUTO_INCREMENT field
            sc.setDatabasePlatform(new SQLitePlatform());
View Full Code Here

TOP

Related Classes of com.avaje.ebean.config.DataSourceConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.