Package org.exoplatform.services.jcr.impl.storage.jdbc.init

Examples of org.exoplatform.services.jcr.impl.storage.jdbc.init.DBInitializer


    *           on I/O error
    */
   protected DBInitializer defaultDBInitializer(String sqlPath) throws NamingException, RepositoryException,
      IOException
   {
      return new DBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
   }
View Full Code Here


    *           on I/O error
    */
   protected void initDatabase() throws NamingException, RepositoryException, IOException
   {

      DBInitializer dbInitilizer = null;
      String sqlPath = null;
      if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
      {
         LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
         // sample of connection factory customization
         if (dbSourceName != null)
            this.connFactory = defaultConnectionFactory();
         else
            this.connFactory =
               new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);

         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";

         // a particular db initializer may be configured here too
         dbInitilizer = new OracleDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
         dbInitilizer = new OracleDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.pgsql.sql";
         dbInitilizer = new PgSQLDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_MYSQL)
      {
         // [PN] 28.06.07
         if (dbSourceName != null)
         {
            DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
            if (ds != null)
               this.connFactory =
                  new MySQLConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
                     swapDirectory, swapCleaner);
            else
               throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
         }
         else
            this.connFactory =
               new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);

         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8)
      {
         // [PN] 13.07.08
         if (dbSourceName != null)
         {
            DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
            if (ds != null)
               this.connFactory =
                  new MySQLConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
                     swapDirectory, swapCleaner);
            else
               throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
         }
         else
            this.connFactory =
               new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);

         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql-utf8.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mssql.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_DERBY)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.derby.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_DB2)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2v8.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sybase.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ingres.sql";
         // using Postgres initializer
         dbInitilizer =
            new IngresSQLDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB)
      {
         if (dbSourceName != null)
         {
            DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
            if (ds != null)
               this.connFactory =
                  new HSQLDBConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
                     swapDirectory, swapCleaner);
            else
               throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
         }
         else
            this.connFactory =
               new HSQLDBConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else
      {
         // generic, DB_HSQLDB
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }

      // database type
      try
      {
         dbInitilizer.init();
      }
      catch (DBInitializerException e)
      {
         LOG.error("Error of init db " + e, e);
      }
View Full Code Here

   *           on I/O error
   */
  protected DBInitializer defaultDBInitializer(String sqlPath) throws NamingException,
                                                              RepositoryException,
                                                              IOException {
    return new DBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
  }
View Full Code Here

   * @throws IOException
   *           on I/O error
   */
  protected void initDatabase() throws NamingException, RepositoryException, IOException {

    DBInitializer dbInitilizer = null;
    String sqlPath = null;
    if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI) {
      LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
      // sample of connection factory customization
      if (dbSourceName != null)
        this.connFactory = defaultConnectionFactory();
      else
        this.connFactory = new OracleConnectionFactory(dbDriver,
                                                       dbUrl,
                                                       dbUserName,
                                                       dbPassword,
                                                       containerName,
                                                       multiDb,
                                                       valueStorageProvider,
                                                       maxBufferSize,
                                                       swapDirectory,
                                                       swapCleaner);

      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";

      // a particular db initializer may be configured here too
      dbInitilizer = new OracleDBInitializer(containerName,
                                             this.connFactory.getJdbcConnection(),
                                             sqlPath,
                                             multiDb);
    } else if (dbDialect == DBConstants.DB_DIALECT_ORACLE) {
      this.connFactory = defaultConnectionFactory();
      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
      dbInitilizer = new OracleDBInitializer(containerName,
                                             this.connFactory.getJdbcConnection(),
                                             sqlPath,
                                             multiDb);
    } else if (dbDialect == DBConstants.DB_DIALECT_PGSQL) {
      this.connFactory = defaultConnectionFactory();
      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.pgsql.sql";
      dbInitilizer = new PgSQLDBInitializer(containerName,
                                            this.connFactory.getJdbcConnection(),
                                            sqlPath,
                                            multiDb);
    } else if (dbDialect == DBConstants.DB_DIALECT_MYSQL) {
      // [PN] 28.06.07
      if (dbSourceName != null) {
        DataSource ds = (DataSource) new InitialContext().lookup(dbSourceName);
        if (ds != null)
          this.connFactory = new MySQLConnectionFactory(ds,
                                                        containerName,
                                                        multiDb,
                                                        valueStorageProvider,
                                                        maxBufferSize,
                                                        swapDirectory,
                                                        swapCleaner);
        else
          throw new RepositoryException("Datasource '" + dbSourceName
              + "' is not bound in this context.");
      } else
        this.connFactory = new MySQLConnectionFactory(dbDriver,
                                                      dbUrl,
                                                      dbUserName,
                                                      dbPassword,
                                                      containerName,
                                                      multiDb,
                                                      valueStorageProvider,
                                                      maxBufferSize,
                                                      swapDirectory,
                                                      swapCleaner);

      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql.sql";
      dbInitilizer = defaultDBInitializer(sqlPath);
    } else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8) {
      // [PN] 13.07.08
      if (dbSourceName != null) {
        DataSource ds = (DataSource) new InitialContext().lookup(dbSourceName);
        if (ds != null)
          this.connFactory = new MySQLConnectionFactory(ds,
                                                        containerName,
                                                        multiDb,
                                                        valueStorageProvider,
                                                        maxBufferSize,
                                                        swapDirectory,
                                                        swapCleaner);
        else
          throw new RepositoryException("Datasource '" + dbSourceName
              + "' is not bound in this context.");
      } else
        this.connFactory = new MySQLConnectionFactory(dbDriver,
                                                      dbUrl,
                                                      dbUserName,
                                                      dbPassword,
                                                      containerName,
                                                      multiDb,
                                                      valueStorageProvider,
                                                      maxBufferSize,
                                                      swapDirectory,
                                                      swapCleaner);

      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql-utf8.sql";
      dbInitilizer = defaultDBInitializer(sqlPath);
    } else if (dbDialect == DBConstants.DB_DIALECT_MSSQL) {
      this.connFactory = defaultConnectionFactory();
      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mssql.sql";
      dbInitilizer = defaultDBInitializer(sqlPath);
    } else if (dbDialect == DBConstants.DB_DIALECT_DERBY) {
      this.connFactory = defaultConnectionFactory();
      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.derby.sql";
      dbInitilizer = defaultDBInitializer(sqlPath);
    } else if (dbDialect == DBConstants.DB_DIALECT_DB2) {
      this.connFactory = defaultConnectionFactory();
      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2.sql";
      dbInitilizer = defaultDBInitializer(sqlPath);
    } else if (dbDialect == DBConstants.DB_DIALECT_DB2V8) {
      this.connFactory = defaultConnectionFactory();
      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2v8.sql";
      dbInitilizer = defaultDBInitializer(sqlPath);
    } else if (dbDialect == DBConstants.DB_DIALECT_SYBASE) {
      this.connFactory = defaultConnectionFactory();
      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sybase.sql";
      dbInitilizer = defaultDBInitializer(sqlPath);
    } else if (dbDialect == DBConstants.DB_DIALECT_INGRES) {
      this.connFactory = defaultConnectionFactory();
      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ingres.sql";
      // using Postgres initializer
      dbInitilizer = new IngresSQLDBInitializer(containerName,
                                            this.connFactory.getJdbcConnection(),
                                            sqlPath,
                                            multiDb);
    } else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB) {
    if (dbSourceName != null) {
      DataSource ds = (DataSource) new InitialContext()
          .lookup(dbSourceName);
      if (ds != null)
        this.connFactory = new HSQLDBConnectionFactory(ds,
            containerName, multiDb, valueStorageProvider,
            maxBufferSize, swapDirectory, swapCleaner);
      else
        throw new RepositoryException("Datasource '" + dbSourceName
            + "' is not bound in this context.");
    } else
      this.connFactory = new HSQLDBConnectionFactory(dbDriver, dbUrl,
          dbUserName, dbPassword, containerName, multiDb,
          valueStorageProvider, maxBufferSize, swapDirectory,
          swapCleaner);
    sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
    dbInitilizer = defaultDBInitializer(sqlPath);
    } else {
      // generic, DB_HSQLDB
      this.connFactory = defaultConnectionFactory();
      sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
      dbInitilizer = defaultDBInitializer(sqlPath);
    }

    // database type
    try {
      dbInitilizer.init();
    } catch (DBInitializerException e) {
      LOG.error("Error of init db " + e, e);
    }
  }
View Full Code Here

    *           on I/O error
    */
   protected DBInitializer defaultDBInitializer(String sqlPath) throws NamingException, RepositoryException,
      IOException
   {
      return new DBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
   }
View Full Code Here

    *           on I/O error
    */
   protected void initDatabase() throws NamingException, RepositoryException, IOException
   {

      DBInitializer dbInitilizer = null;
      String sqlPath = null;
      if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
      {
         LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
         // sample of connection factory customization
         if (dbSourceName != null)
            this.connFactory = defaultConnectionFactory();
         else
            this.connFactory =
               new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);

         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";

         // a particular db initializer may be configured here too
         dbInitilizer = new OracleDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
         dbInitilizer = new OracleDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.pgsql.sql";
         dbInitilizer = new PgSQLDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_MYSQL)
      {
         // [PN] 28.06.07
         if (dbSourceName != null)
         {
            DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
            if (ds != null)
               this.connFactory =
                  new MySQLConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
                     swapDirectory, swapCleaner);
            else
               throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
         }
         else
            this.connFactory =
               new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);

         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8)
      {
         // [PN] 13.07.08
         if (dbSourceName != null)
         {
            DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
            if (ds != null)
               this.connFactory =
                  new MySQLConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
                     swapDirectory, swapCleaner);
            else
               throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
         }
         else
            this.connFactory =
               new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);

         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql-utf8.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mssql.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_DERBY)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.derby.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_DB2)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2v8.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sybase.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ingres.sql";
         // using Postgres initializer
         dbInitilizer =
            new IngresSQLDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB)
      {
         if (dbSourceName != null)
         {
            DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
            if (ds != null)
               this.connFactory =
                  new HSQLDBConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
                     swapDirectory, swapCleaner);
            else
               throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
         }
         else
            this.connFactory =
               new HSQLDBConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else
      {
         // generic, DB_HSQLDB
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }

      // database type
      try
      {
         dbInitilizer.init();
      }
      catch (DBInitializerException e)
      {
         LOG.error("Error of init db " + e, e);
      }
View Full Code Here

    *           on I/O error
    */
   protected void initDatabase() throws NamingException, RepositoryException, IOException
   {

      DBInitializer dbInitilizer = null;
      String sqlPath = null;
      if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
      {
         LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
         // sample of connection factory customization
         if (dbSourceName != null)
            this.connFactory = defaultConnectionFactory();
         else
            this.connFactory =
               new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);

         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";

         // a particular db initializer may be configured here too
         dbInitilizer = new OracleDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
      {

         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
         dbInitilizer = new OracleDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);

      }
      else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.pgsql.sql";
         dbInitilizer = new PgSQLDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_MYSQL)
      {
         // [PN] 28.06.07
         if (dbSourceName != null)
         {
            DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
            if (ds != null)
               this.connFactory =
                  new MySQLConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
                     swapDirectory, swapCleaner);
            else
               throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
         }
         else
            this.connFactory =
               new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);

         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8)
      {
         // [PN] 13.07.08
         if (dbSourceName != null)
         {
            DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
            if (ds != null)
               this.connFactory =
                  new MySQLConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
                     swapDirectory, swapCleaner);
            else
               throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
         }
         else
            this.connFactory =
               new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);

         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql-utf8.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mssql.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_DERBY)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.derby.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_DB2)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2v8.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sybase.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
      {
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ingres.sql";
         // using Postgres initializer
         dbInitilizer =
            new IngresSQLDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
      }
      else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB)
      {
         if (dbSourceName != null)
         {
            DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
            if (ds != null)
               this.connFactory =
                  new HSQLDBConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
                     swapDirectory, swapCleaner);
            else
               throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
         }
         else
            this.connFactory =
               new HSQLDBConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
                  valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }
      else
      {
         // generic, DB_HSQLDB
         this.connFactory = defaultConnectionFactory();
         sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
         dbInitilizer = defaultDBInitializer(sqlPath);
      }

      // database type
      try
      {
         dbInitilizer.init();
      }
      catch (DBInitializerException e)
      {
         LOG.error("Error of init db " + e, e);
      }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.storage.jdbc.init.DBInitializer

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.