Package org.apache.ddlutils

Examples of org.apache.ddlutils.Platform


              generator.addTable(c);
            }
            // get the Database model
      Database database = generator.getDatabase();
 
      Platform platform = PlatformFactory.createNewPlatformInstance(ddlType);
      platform.setDataSource(DB.datasource);
      // siena.ddl can have create/update/ddl
      // if siena.ddl is defined, uses it
      // if not:
      // in dev mode, will be update by default
      // in prod mode, will be none by default
      String ddl = "none";
      if(Play.mode.isDev()){
        ddl = Play.configuration.getProperty("siena.ddl", "update");
        Logger.debug("Siena DDL dev mode: %s", ddl);
      }else if(Play.mode.isProd()){
        ddl = Play.configuration.getProperty("siena.ddl", "none");
        Logger.debug("Siena DDL prod mode: %s", ddl);       
      }

      if("create".equals(ddl)){
          if(Logger.isDebugEnabled()) {
              Logger.debug("Siena DDL Generator SQL: %s", platform.getCreateModelSql(database, false, false));
          }
        // creates tables and do not drop tables and do not continues on error
        try {
          platform.createModel(connection, database, false, false);
        }catch(DatabaseOperationException ex){
          Logger.warn("Siena DDL createTables generated exception:%s", ex.getCause()!=null?ex.getCause():ex.getMessage());
        }
      }else if("update".equals(ddl)){
        Database currentDatabase = platform.readModelFromDatabase(connection, ddlType);
       
        if(!disableJPA){
          // Remove from the current schema those tables that are not known by Siena,
            // since they're likely to be JPA classes.
            // Iterate in reverse order since removeTable() changes the list size.
            for (int i = currentDatabase.getTableCount() - 1; i >= 0; i--) {
                Table table = currentDatabase.getTable(i);
                if(database.findTable(table.getName(), false) == null){
                    Logger.debug("Keeping existing table %s", table.getName());
                    currentDatabase.removeTable(i);
                }
            }
        }
       
        if(Logger.isDebugEnabled()){
            Logger.debug("Siena DDL Generator SQL: %s", platform.getAlterModelSql(currentDatabase, database));
        }

                // alters tables and continues on error
        platform.alterModel(currentDatabase, database, true);
      }
     
      // activate lifecycle or not
      if(useLifecycle()){
        Logger.debug("Siena activating lifecycle management");
View Full Code Here


      }
 
      // get the Database model
      Database database = generator.getDatabase();
 
      Platform platform = PlatformFactory.createNewPlatformInstance("postgresql");
      Class.forName(driver);
      Connection connection = DriverManager.getConnection(url, username, password);
     
      System.out.println(platform.getAlterTablesSql(connection, database));
     
      // this will perform the database changes
      platform.alterTables(connection, database, true);
 
      connection.close();
     
      pm = new PostgresqlPersistenceManager();
      pm.init(p);
View Full Code Here

      }
 
      // get the Database model
      Database database = generator.getDatabase();
 
      Platform platform = PlatformFactory.createNewPlatformInstance(dataSource);
      Class.forName("org.drizzle.jdbc.DrizzleDriver");
      Connection connection = DriverManager.getConnection(url);
     
      System.out.println(platform.getAlterTablesSql(connection, database));
     
      // this will perform the database changes
      platform.alterTables(connection, database, true);
 
      connection.close();
     
      pm = new JdbcPersistenceManager();
      pm.init(p);
View Full Code Here

      }
 
      // get the Database model
      Database database = generator.getDatabase();
 
      Platform platform = PlatformFactory.createNewPlatformInstance("postgresql");
      Class.forName(driver);
      Connection connection = DriverManager.getConnection(url, username, password);
     
      System.out.println(platform.getAlterTablesSql(connection, database));
     
      // this will perform the database changes
      platform.alterTables(connection, database, true);
 
      connection.close();
     
      pm = new PostgresqlPersistenceManager();
      pm.init(p);
View Full Code Here

      }
 
      // get the Database model
      Database database = generator.getDatabase();
 
      Platform platform = PlatformFactory.createNewPlatformInstance("mysql");
      Class.forName(driver);
      //JdbcDataSource ds = new JdbcDataSource();
      //ds.setURL(url);
      //Connection connection = ds.getConnection();
      Connection connection = DriverManager.getConnection(url, username, password);
     
      System.out.println(platform.getAlterTablesSql(connection, database));
     
      // this will perform the database changes
      platform.alterTables(connection, database, true);
 
      connection.close();
     
      pm = new H2PersistenceManager();
      pm.init(p);
View Full Code Here

      }
 
      // get the Database model
      Database database = generator.getDatabase();
 
      Platform platform = PlatformFactory.createNewPlatformInstance("mysql");
      Class.forName("com.mysql.jdbc.Driver");
      Connection connection = DriverManager.getConnection(url, username, password);
     
      System.out.println(platform.getAlterTablesSql(connection, database));
     
      // this will perform the database changes
      platform.alterTables(connection, database, true);
 
      connection.close();
     
      pm = new JdbcPersistenceManager();
      pm.init(p);
View Full Code Here

      }
 
      // get the Database model
      Database database = generator.getDatabase();
 
      Platform platform = PlatformFactory.createNewPlatformInstance("mysql");
      Class.forName(driver);
      //JdbcDataSource ds = new JdbcDataSource();
      //ds.setURL(url);
      //Connection connection = ds.getConnection();
      Connection connection = DriverManager.getConnection(url, username, password);
     
      System.out.println(platform.getAlterTablesSql(connection, database));
     
      // this will perform the database changes
      platform.alterTables(connection, database, true);
 
      connection.close();
     
      pm = new H2PersistenceManager();
      pm.init(p);
View Full Code Here

      }
 
      // get the Database model
      Database database = generator.getDatabase();
 
      Platform platform = PlatformFactory.createNewPlatformInstance("mysql");
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      Connection connection = DriverManager.getConnection(url, username, password);
     
      System.out.println(platform.getAlterTablesSql(connection, database));
     
      // this will perform the database changes
      CreationParameters cp = new CreationParameters();
      // to search, it requires MyISAM
      cp.addParameter(database.findTable("discoveries_search"), "ENGINE", "MyISAM");
      cp.addParameter(database.findTable("discoveries_search2"), "ENGINE", "MyISAM");

      platform.alterTables(connection, database, cp, true);
     
 
      connection.close();
     
      pm = new JdbcPersistenceManager();
View Full Code Here

      }
 
      // get the Database model
      Database database = generator.getDatabase();
 
      Platform platform = PlatformFactory.createNewPlatformInstance("mysql");
      Class.forName(driver);
      //JdbcDataSource ds = new JdbcDataSource();
      //ds.setURL(url);
      //Connection connection = ds.getConnection();
      Connection connection = DriverManager.getConnection(url, username, password);
     
      System.out.println(platform.getAlterTablesSql(connection, database));
     
      // this will perform the database changes
      platform.alterTables(connection, database, true);
 
      connection.close();
     
      pm = new H2PersistenceManager();
      pm.init(p);
View Full Code Here

      }
 
      // get the Database model
      Database database = generator.getDatabase();
 
      Platform platform = PlatformFactory.createNewPlatformInstance("mysql");
      Class.forName("com.mysql.jdbc.Driver");
      Connection connection = DriverManager.getConnection(url, username, password);
     
      System.out.println(platform.getAlterTablesSql(connection, database));
     
      // this will perform the database changes
      platform.alterTables(connection, database, true);
 
      connection.close();
     
      pm = new JdbcPersistenceManager();
      pm.init(p);
View Full Code Here

TOP

Related Classes of org.apache.ddlutils.Platform

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.