Examples of DatabaseMeta


Examples of org.pentaho.di.core.database.DatabaseMeta

    if (validationHasErrors && !continueOnValidationErrors) {
      return null;
    }
   
    try {
      DatabaseMeta dbMeta = connectionModel.getDatabaseMeta();
      final String mondrianConnectionUrl = MessageFormat.format(
          "Provider={0};Jdbc={1};JdbcUser={2};JdbcPassword={3};Catalog={4};JdbcDrivers={5}", "Mondrian", dbMeta.getURL(), dbMeta
              .getUsername(), dbMeta.getPassword(), "file:" + getMondrianSchemaFilename(),
              dbMeta.getDriverClass());
     
      Map<Parameter, Object> parameterValues = new HashMap<Parameter, Object>();

      parameterValues.put(mondrianSchemaLoader.getParameters().get(0), mondrianConnectionUrl);
      parameterValues.put(mondrianSchemaLoader.getParameters().get(1), cubeName);
View Full Code Here

Examples of org.pentaho.di.core.database.DatabaseMeta

   
    // special binding based on type of database meta
    BindingConvertor<Boolean, Boolean> converter = new BindingConvertor<Boolean, Boolean>() {
      @Override
      public Boolean sourceToTarget(Boolean value) {
        DatabaseMeta databaseMeta = connectionModel.getDatabaseMeta();
        boolean disabled = connectionModel.isSchemaLocked();
       
        if (disabled && isSelected()) {
          setSelected(false);
        }
View Full Code Here

Examples of org.pentaho.di.core.database.DatabaseMeta

  private void setData(final JdbcConnectionDefinition def)
  {
    if (def instanceof DriverConnectionDefinition)
    {
      final DriverConnectionDefinition jdbcDef = (DriverConnectionDefinition) def;
      this.meta = new DatabaseMeta();
      this.meta.setUsername(jdbcDef.getUsername());
      this.meta.setPassword(jdbcDef.getPassword());
      this.meta.setName(jdbcDef.getName());

      if (jdbcDef.getDatabaseType() != null)
      {
        log.debug("Database type is known: " + jdbcDef.getDatabaseType());
        try
        {
          this.meta.setDatabaseType(jdbcDef.getDatabaseType());
        }
        catch (RuntimeException re)
        {
          // sic!
        }
        this.meta.setDBName(jdbcDef.getDatabaseName());
        this.meta.setHostname(jdbcDef.getHostName());
        this.meta.setDBPort(jdbcDef.getPort());
        this.meta.getAttributes().setProperty(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_URL, jdbcDef.getConnectionString());
        this.meta.getAttributes().setProperty(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_DRIVER_CLASS, jdbcDef.getDriverClass());
      }
      else if (String.valueOf(jdbcDef.getConnectionString()).startsWith(HSQLDB_MEM_PREFIX))
      {
        this.meta.setDatabaseType(DatabaseMapping.getGenericInterface().getPluginId());
        this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_URL, jdbcDef.getConnectionString());
        this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_DRIVER_CLASS, jdbcDef.getDriverClass());
      }
      else if (String.valueOf(jdbcDef.getConnectionString()).startsWith(HSQLDB_LOCAL_PREFIX))
      {
         this.meta.setDatabaseType(DatabaseMapping.getGenericInterface().getPluginId());
         this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_URL, jdbcDef.getConnectionString());
         this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_DRIVER_CLASS, jdbcDef.getDriverClass());
      }
      else
      {
        final DatabaseInterface databaseInterface = DatabaseMapping.getMappingForDriver(jdbcDef.getDriverClass());
        this.meta.setDatabaseType(databaseInterface.getPluginId());
        log.debug("Database type is unknown, using " + databaseInterface);
        try
        {
          final String pattern;
          if (databaseInterface instanceof HypersonicDatabaseMeta)
          {
            final String connectionString = jdbcDef.getConnectionString();
            if (connectionString.startsWith(HSQLDB_PREFIX))
            {
              if (connectionString.indexOf(':', HSQLDB_PREFIX.length()) == -1)
              {
                pattern = HSQLDB_PREFIX + "{0}/{2}";
              }
              else
              {
                pattern = HSQLDB_PREFIX + "{0}:{1}/{2}";
              }
            }
            else
            {
              pattern = databaseInterface.getURL("{0}", "{1}", "{2}");
            }
          }
          else
          {
            pattern = databaseInterface.getURL("{0}", "{1}", "{2}");
          }
          // knowing that most databases are written in C, we can be sure that the zero-character
          // is not a common value.
          if (pattern != null && pattern.length() > 0)
          {
            final MessageFormat format = new MessageFormat(pattern);
            final Object[] objects = format.parse(jdbcDef.getConnectionString());
            if (objects[0] != null)
            {
              this.meta.setHostname(String.valueOf(objects[0]));
            }
            if (objects[1] != null)
            {
              this.meta.setDBPort(String.valueOf(objects[1]));
            }
            if (objects[2] != null)
            {
              this.meta.setDBName(String.valueOf(objects[2]));
            }
          }
        }
        catch (Exception e)
        {
          designTimeContext.error(new XulException("Unable to parse database-URL, please report " +
              "your database driver to Pentaho to include it in our list of databases.", e));
          this.meta.setDatabaseType(DatabaseMapping.getGenericInterface().getPluginId());
          this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_URL, jdbcDef.getConnectionString());
          this.meta.getAttributes().put(GenericDatabaseMeta.ATRRIBUTE_CUSTOM_DRIVER_CLASS, jdbcDef.getDriverClass());
        }
      }


      final Properties properties = jdbcDef.getProperties();
      final Iterator entryIterator = properties.entrySet().iterator();
      while (entryIterator.hasNext())
      {
        final Map.Entry entry = (Map.Entry) entryIterator.next();
        final String key = (String) entry.getKey();
        if (key.startsWith("::pentaho-reporting::"))
        {
          continue;
        }
        if ("user".equals(key) || "password".equals(key))
        {
          continue;
        }
        // This line makes the database dialog crash later. This seems to be a Swing/Xul issue.
        this.meta.addExtraOption(meta.getPluginId(), key, (String) entry.getValue());
      }
    }
    else if (def instanceof JndiConnectionDefinition)
    {
      final JndiConnectionDefinition jndiDef = (JndiConnectionDefinition) def;
      this.meta = new DatabaseMeta();
      this.meta.setDBName(jndiDef.getJndiName()); //JNDI name stored in DBname
      this.meta.setName(jndiDef.getName());
      try
      {
        if (jndiDef.getDatabaseType() != null)
View Full Code Here

Examples of org.pentaho.di.core.database.DatabaseMeta

      if (handler.isConfirmed() == false)
      {
        return null;
      }

      final DatabaseMeta database = (DatabaseMeta) handler.getData(); //$NON-NLS-1$
      if (database == null)
      {
        log.debug("DatabaseMeta is null");
        return null;
      }
View Full Code Here

Examples of org.pentaho.di.core.database.DatabaseMeta

  public IPentahoResultSet executeQuery( Query queryObject ) {

    // need to get the correct DatabaseMeta
    SqlPhysicalModel sqlModel = (SqlPhysicalModel) queryObject.getLogicalModel().getPhysicalModel();
    DatabaseMeta databaseMeta = ThinModelConverter.convertToLegacy( sqlModel.getId(), sqlModel.getDatasource() );
    // this connection needs closed
    boolean closeConnection = true;

    DatabaseMeta activeDatabaseMeta = getActiveDatabaseMeta( databaseMeta );
    SQLConnection sqlConnection = getConnection( activeDatabaseMeta );
    String sql = null;
    try {
      if ( ( sqlConnection == null ) || !sqlConnection.initialized() ) {
        logger.error( Messages.getInstance().getErrorString( "SQLBaseComponent.ERROR_0007_NO_CONNECTION" ) ); //$NON-NLS-1$
View Full Code Here

Examples of org.pentaho.di.core.database.DatabaseMeta

      DatabaseInterface di = getDatabaseInterface( tempConnection );

      if ( ( di != null ) && ( !databaseMeta.getPluginId().equals( di.getPluginId() ) ) ) {
        // we need to reinitialize our mqlQuery object and reset the query.
        // note that using this di object wipes out connection info
        DatabaseMeta meta = (DatabaseMeta) databaseMeta.clone();
        DatabaseInterface di2 = (DatabaseInterface) di.clone();
        di2.setAccessType( databaseMeta.getAccessType() );
        di2.setDatabaseName( databaseMeta.getDatabaseName() );
        di2.setAttributes( databaseMeta.getAttributes() );
        di2.setUsername( databaseMeta.getUsername() );
        di2.setPassword( databaseMeta.getPassword() );
        di2.setHostname( databaseMeta.getHostname() );
        meta.setDatabaseInterface( di2 );
        return meta;
      } else {
        return databaseMeta;
      }
    } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.