Package org.pentaho.database

Examples of org.pentaho.database.IDatabaseDialect


    {
      final DataSourceCacheManager cacheManager =
          ClassicEngineBoot.getInstance().getObjectFactory().get(DataSourceCacheManager.class);
      final IDatabaseDialectService databaseDialectService =
          ClassicEngineBoot.getInstance().getObjectFactory().get(IDatabaseDialectService.class);
      final IDatabaseDialect dialect = databaseDialectService.getDialect(databaseConnection);

      final String driverClass;
      if (GENERIC.equals(databaseConnection.getDatabaseType().getShortName())) //$NON-NLS-1$
      {
        driverClass = databaseConnection.getAttributes().get(GenericDatabaseDialect.ATTRIBUTE_CUSTOM_DRIVER_CLASS);
      }
      else
      {
        driverClass = dialect.getNativeDriver();
      }

      String url;
      try
      {
        url = dialect.getURLWithExtraOptions(databaseConnection);
      }
      catch (DatabaseDialectException e)
      {
        url = null;
      }
View Full Code Here


  public static DataSource convert(final IDatabaseConnection databaseConnection)
  {
    final BasicDataSource basicDatasource = new BasicDataSource();
    final IDatabaseDialectService databaseDialectService =
        ClassicEngineBoot.getInstance().getObjectFactory().get(IDatabaseDialectService.class);
    final IDatabaseDialect dialect = databaseDialectService.getDialect(databaseConnection);
    if ("GENERIC".equals(databaseConnection.getDatabaseType().getShortName()))//$NON-NLS-1$
    {
      basicDatasource.setDriverClassName(databaseConnection.getAttributes().get(GenericDatabaseDialect.ATTRIBUTE_CUSTOM_DRIVER_CLASS));
    }
    else
    {
      basicDatasource.setDriverClassName(dialect.getNativeDriver());
    }
    try
    {
      basicDatasource.setUrl(dialect.getURLWithExtraOptions(databaseConnection));
    }
    catch (DatabaseDialectException e)
    {
      basicDatasource.setUrl(null);
    }
View Full Code Here

      if ( databaseDialectService == null ) {
        throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
            "PooledDatasourceHelper.ERROR_0005_UNABLE_TO_POOL_DATASOURCE_NO_DIALECT_SERVICE",
            databaseConnection.getName() ) );
      }
      IDatabaseDialect dialect = databaseDialectService.getDialect( databaseConnection );
      if ( dialect == null || dialect.getDatabaseType() == null ) {
        throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
            "PooledDatasourceHelper.ERROR_0004_UNABLE_TO_POOL_DATASOURCE_NO_DIALECT", databaseConnection.getName() ) );
      }
      if ( databaseConnection.getDatabaseType().getShortName().equals( "GENERIC" ) ) { //$NON-NLS-1$
        driverClass = databaseConnection.getAttributes().get( GenericDatabaseDialect.ATTRIBUTE_CUSTOM_DRIVER_CLASS );
        if ( StringUtils.isEmpty( driverClass ) ) {
          throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
              "PooledDatasourceHelper.ERROR_0006_UNABLE_TO_POOL_DATASOURCE_NO_CLASSNAME", databaseConnection.getName() ) );
        }

      } else {
        driverClass = dialect.getNativeDriver();
        if ( StringUtils.isEmpty( driverClass ) ) {
          throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
              "PooledDatasourceHelper.ERROR_0007_UNABLE_TO_POOL_DATASOURCE_NO_DRIVER", databaseConnection.getName() ) );
        }
      }
      try {
        url = dialect.getURLWithExtraOptions( databaseConnection );
      } catch ( DatabaseDialectException e ) {
        url = null;
      }

      // Read default connection pooling parameter
View Full Code Here

  public static DataSource convert( IDatabaseConnection databaseConnection ) throws DBDatasourceServiceException {
    DriverManagerDataSource basicDatasource = new DriverManagerDataSource(); // From Spring
    IDatabaseDialectService databaseDialectService =
        PentahoSystem.get( IDatabaseDialectService.class, PentahoSessionHolder.getSession() );
    IDatabaseDialect dialect = databaseDialectService.getDialect( databaseConnection );
    if ( databaseConnection.getDatabaseType() == null && dialect == null ) {
      // We do not have enough information to create a DataSource. Throwing exception
      throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
          "PooledDatasourceHelper.ERROR_0001_DATASOURCE_CREATE_ERROR_NO_DIALECT", databaseConnection.getName() ) );
    }

    if ( databaseConnection.getDatabaseType().getShortName().equals( "GENERIC" ) ) { //$NON-NLS-1$
      String driverClassName =
          databaseConnection.getAttributes().get( GenericDatabaseDialect.ATTRIBUTE_CUSTOM_DRIVER_CLASS );
      if ( !StringUtils.isEmpty( driverClassName ) ) {
        basicDatasource.setDriverClassName( driverClassName );
      } else {
        // We do not have enough information to create a DataSource. Throwing exception
        throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
            "PooledDatasourceHelper.ERROR_0002_DATASOURCE_CREATE_ERROR_NO_CLASSNAME", databaseConnection.getName() ) );
      }

    } else {
      if ( !StringUtils.isEmpty( dialect.getNativeDriver() ) ) {
        basicDatasource.setDriverClassName( dialect.getNativeDriver() );
      } else {
        // We do not have enough information to create a DataSource. Throwing exception
        throw new DBDatasourceServiceException( Messages.getInstance().getErrorString(
            "PooledDatasourceHelper.ERROR_0003_DATASOURCE_CREATE_ERROR_NO_DRIVER", databaseConnection.getName() ) );
      }

    }
    try {
      basicDatasource.setUrl( dialect.getURLWithExtraOptions( databaseConnection ) );
    } catch ( DatabaseDialectException e ) {
      basicDatasource.setUrl( null );
    }
    basicDatasource.setUsername( databaseConnection.getUsername() );
    basicDatasource.setPassword( databaseConnection.getPassword() );
View Full Code Here

TOP

Related Classes of org.pentaho.database.IDatabaseDialect

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.