当前位置: 首页>>代码示例>>Java>>正文


Java Database.connect方法代码示例

本文整理汇总了Java中org.pentaho.di.core.database.Database.connect方法的典型用法代码示例。如果您正苦于以下问题:Java Database.connect方法的具体用法?Java Database.connect怎么用?Java Database.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.core.database.Database的用法示例。


在下文中一共展示了Database.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInputData

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public boolean getInputData()
{
	// Get some data...
	CopyTableWizardPage1 page1 = (CopyTableWizardPage1)getPreviousPage();
	
	Database sourceDb = new Database(CopyTableWizard.loggingObject, page1.getSourceDatabase());
	try
	{
		sourceDb.connect();
		input = sourceDb.getTablenames();
	}
	catch(KettleDatabaseException dbe)
	{
		new ErrorDialog(shell, BaseMessages.getString(PKG, "CopyTableWizardPage2.ErrorGettingTables.DialogTitle"), BaseMessages.getString(PKG, "CopyTableWizardPage2.ErrorGettingTables.DialogMessage"), dbe); //$NON-NLS-1$ //$NON-NLS-2$
		input = null;
		return false;
	}
	finally
	{
		sourceDb.disconnect();
	}
	return true;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:24,代码来源:CopyTableWizardPage2.java

示例2: getInputData

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public boolean getInputData()
{
	// Get some data...
	CopyTableWizardPage1 page1 = (CopyTableWizardPage1)getPreviousPage();
	
	Database sourceDb = new Database(page1.getSourceDatabase());
	try
	{
		sourceDb.connect();
		input = sourceDb.getTablenames();
	}
	catch(KettleDatabaseException dbe)
	{
		new ErrorDialog(shell, Messages.getString("CopyTableWizardPage2.ErrorGettingTables.DialogTitle"), Messages.getString("CopyTableWizardPage2.ErrorGettingTables.DialogMessage"), dbe); //$NON-NLS-1$ //$NON-NLS-2$
		input = null;
		return false;
	}
	finally
	{
		sourceDb.disconnect();
	}
	return true;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:24,代码来源:CopyTableWizardPage2.java

示例3: getSchemaNames

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Presents a dialog box to select a schema from the database.  Then sets the selected schema in the dialog
 */
private void getSchemaNames() {
  DatabaseMeta databaseMeta = transMeta.findDatabase( wConnection.getText() );
  if ( databaseMeta != null ) {
    Database database = new Database( loggingObject, databaseMeta );
    try {
      database.connect();
      String[] schemas = database.getSchemas();

      if ( null != schemas && schemas.length > 0 ) {
        schemas = Const.sortStrings( schemas );
        EnterSelectionDialog dialog =
                new EnterSelectionDialog( shell, schemas, BaseMessages.getString(
                        PKG, "SnowflakeBulkLoader.Dialog.AvailableSchemas.Title", wConnection.getText() ), BaseMessages
                        .getString( PKG, "SnowflakeBulkLoader.Dialog.AvailableSchemas.Message", wConnection.getText() ) );
        String d = dialog.open();
        if ( d != null ) {
          wSchema.setText( Const.NVL( d, "" ) );
          setTableFieldCombo();
        }

      } else {
        MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
        mb.setMessage( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.NoSchema.Error" ) );
        mb.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.GetSchemas.Error" ) );
        mb.open();
      }
    } catch ( Exception e ) {
      new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.Error.Title" ), BaseMessages
              .getString( PKG, "SnowflakeBulkLoader.Dialog.ErrorGettingSchemas" ), e );
    } finally {
      database.disconnect();
    }
  }
}
 
开发者ID:inquidia,项目名称:PentahoSnowflakePlugin,代码行数:38,代码来源:SnowflakeBulkLoaderDialog.java

示例4: getRequiredFields

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Gets a list of fields in the database table
 * @param space The variable space
 * @return The metadata about the fields in the table.
 * @throws KettleException
 */
public RowMetaInterface getRequiredFields( VariableSpace space ) throws KettleException {
  String realTableName = space.environmentSubstitute( targetTable );
  String realSchemaName = space.environmentSubstitute( targetSchema );

  if ( databaseMeta != null ) {
    Database db = new Database( loggingObject, databaseMeta );
    try {
      db.connect();

      if ( !Const.isEmpty( realTableName ) ) {
        String schemaTable = databaseMeta.getQuotedSchemaTableCombination( realSchemaName, realTableName );

        // Check if this table exists...
        if ( db.checkTableExists( schemaTable ) ) {
          return db.getTableFields( schemaTable );
        } else {
          throw new KettleException( BaseMessages.getString( PKG, "SnowflakeBulkLoaderMeta.Exception.TableNotFound" ) );
        }
      } else {
        throw new KettleException( BaseMessages.getString( PKG, "SnowflakeBulkLoaderMeta.Exception.TableNotSpecified" ) );
      }
    } catch ( Exception e ) {
      throw new KettleException(
        BaseMessages.getString( PKG, "SnowflakeBulkLoaderMeta.Exception.ErrorGettingFields" ), e );
    } finally {
      db.disconnect();
    }
  } else {
    throw new KettleException( BaseMessages.getString( PKG, "SnowflakeBulkLoaderMeta.Exception.ConnectionNotDefined" ) );
  }

}
 
开发者ID:inquidia,项目名称:PentahoSnowflakePlugin,代码行数:39,代码来源:SnowflakeBulkLoaderMeta.java

示例5: clearLogTable

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
    * User requested to clear the log table.<br>
    * Better ask confirmation
    */
   public void clearLogTable() {
   	String logTable = jobGraph.getManagedObject().getLogTable();
   	DatabaseMeta databaseMeta = jobGraph.getManagedObject().getLogConnection();
   	
   	if (databaseMeta!=null && !Const.isEmpty(logTable)) {
   	
    	MessageBox mb = new MessageBox(jobGraph.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
        mb.setMessage(Messages.getString("JobGraph.Dialog.AreYouSureYouWantToRemoveAllLogEntries.Message", logTable)); // Nothing found that matches your criteria
		mb.setText(Messages.getString("JobGraph.Dialog.AreYouSureYouWantToRemoveAllLogEntries.Title")); // Sorry!
		if (mb.open()==SWT.YES) {
			Database database = new Database(databaseMeta);
			try {
				database.connect();
				database.truncateTable(logTable);
			}
			catch(Exception e) {
				new ErrorDialog(jobGraph.getShell(), Messages.getString("JobGraph.Dialog.ErrorClearningLoggingTable.Title"), 
						Messages.getString("JobGraph.Dialog.ErrorClearningLoggingTable.Message"), e);
			}
			finally
			{
				if (database!=null) {
					database.disconnect();
				}
				
				refreshHistory();
				wText.setText("");
			}
		}

   	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:37,代码来源:JobHistoryDelegate.java

示例6: getSQLStatements

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev)
{
	SQLStatement retval = new SQLStatement(stepMeta.getName(), database, null); // default: nothing to do!

	if (useDatabase) // Otherwise, don't bother!
	{
		if (database!=null)
		{
			Database db = new Database(loggingObject, database);
			db.shareVariablesWith(transMeta);
			try
			{
				db.connect();
				if (!db.checkSequenceExists(schemaName, sequenceName))
				{
					String cr_table = db.getCreateSequenceStatement(sequenceName, startAt, incrementBy, maxValue, true);
					retval.setSQL(cr_table);
				}
				else
				{
					retval.setSQL(null); // Empty string means: nothing to do: set it to null...
				}
			}
			catch(KettleException e)
			{
				retval.setError(BaseMessages.getString(PKG, "AddSequenceMeta.ErrorMessage.UnableToConnectDB")+Const.CR+e.getMessage()); //$NON-NLS-1$
			}
			finally
			{
				db.disconnect();
			}
		}
		else
		{
			retval.setError(BaseMessages.getString(PKG, "AddSequenceMeta.ErrorMessage.NoConnectionDefined")); //$NON-NLS-1$
		}
	}

	return retval;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:41,代码来源:AddSequenceMeta.java

示例7: getListColumns

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Get a list of columns
 */
private void getListColumns()
{
	if (!Const.isEmpty(wTablename.getText()))
	{
		DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
		if (databaseMeta!=null)
		{
			Database database = new Database(databaseMeta);
			database.shareVariablesWith(jobMeta);
			try
			{
				database.connect();
				String schemaTable = databaseMeta.getQuotedSchemaTableCombination(jobMeta.environmentSubstitute(wSchemaname.getText()), jobMeta.environmentSubstitute(wTablename.getText()));
				RowMetaInterface row = database.getTableFields(schemaTable);
				if(row!=null)
				{
					String available[] = row.getFieldNames();
			
					wFields.removeAll();
					for (int i=0;i<available.length;i++) 
					{
						wFields.add(available[i]);
					}
					wFields.removeEmptyRows();
					wFields.setRowNums();
				}else
				{
					MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR );
					mb.setMessage(Messages.getString("JobEntryColumnsExist.GetListColumsNoRow.DialogMessage"));
					mb.setText(Messages.getString("System.Dialog.Error.Title"));
					mb.open(); 
				}
			}
			catch(Exception e)
			{
				new ErrorDialog(shell, Messages.getString("System.Dialog.Error.Title"), Messages.getString("JobEntryColumnsExist.ConnectionError2.DialogMessage",wTablename.getText()), e);
			}
			finally
			{
				database.disconnect();
			}
		}
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:48,代码来源:JobEntryColumnsExistDialog.java

示例8: getSQLStatements

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev) throws KettleStepException
{
	SQLStatement retval = new SQLStatement(stepMeta.getName(), databaseMeta, null); // default: nothing to do!

	if (databaseMeta!=null)
	{
		if (prev!=null && prev.size()>0)
		{
               // Copy the row
               RowMetaInterface tableFields = new RowMeta();

               // Now change the field names
               for (int i=0;i<fieldTable.length;i++)
               {
                   ValueMetaInterface v = prev.searchValueMeta(fieldStream[i]);
                   if (v!=null)
                   {
                       ValueMetaInterface tableField = v.clone();
                       tableField.setName(fieldTable[i]);
                       tableFields.addValueMeta(tableField);
                   }
                   else
                   {
                       throw new KettleStepException("Unable to find field ["+fieldStream[i]+"] in the input rows");
                   }
               }

			if (!Const.isEmpty(tableName))
			{
                   Database db = new Database(loggingObject, databaseMeta);
                   db.shareVariablesWith(transMeta);
				try
				{
					db.connect();

                       String schemaTable = databaseMeta.getQuotedSchemaTableCombination(transMeta.environmentSubstitute(schemaName), 
                       		                                                          transMeta.environmentSubstitute(tableName));                        
					String sql = db.getDDL(schemaTable,
												tableFields,
												null,
												false,
												null,
												true
												);

					if (sql.length()==0) retval.setSQL(null); else retval.setSQL(sql);
				}
				catch(KettleException e)
				{
					retval.setError(BaseMessages.getString(PKG, "OraBulkLoaderMeta.GetSQL.ErrorOccurred")+e.getMessage()); //$NON-NLS-1$
				}
			}
			else
			{
				retval.setError(BaseMessages.getString(PKG, "OraBulkLoaderMeta.GetSQL.NoTableDefinedOnConnection")); //$NON-NLS-1$
			}
		}
		else
		{
			retval.setError(BaseMessages.getString(PKG, "OraBulkLoaderMeta.GetSQL.NotReceivingAnyFields")); //$NON-NLS-1$
		}
	}
	else
	{
		retval.setError(BaseMessages.getString(PKG, "OraBulkLoaderMeta.GetSQL.NoConnectionDefined")); //$NON-NLS-1$
	}

	return retval;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:70,代码来源:OraBulkLoaderMeta.java

示例9: getLookup

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Get the fields from the table in the database and use them as lookup 
 * keys. Only get the the fields which are not yet in use as key, or in 
 * the field table. Also ignore technical key, version, fromdate, todate.
 */
private void getLookup()
{
	DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
	if (databaseMeta!=null)
	{
		Database db = new Database(databaseMeta);
		db.shareVariablesWith(transMeta);
		try
		{
			db.connect();
               String schemaTable = databaseMeta.getQuotedSchemaTableCombination(wSchema.getText(), wTable.getText()); 
			RowMetaInterface r = db.getTableFields(schemaTable);
			if (r!=null && !r.isEmpty())
			{
                   BaseStepDialog.getFieldsFromPrevious(r, wUpIns, 2, new int[] { 1, 2 }, new int[] { 3 }, -1, -1, new TableItemInsertListener()
                       {
                           public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v)
                           {
                               int idx = wKey.indexOfString(v.getName(), 2);
                               if ( idx<0 &&
                                   !v.getName().equalsIgnoreCase(wTk.getText()) &&
                                   !v.getName().equalsIgnoreCase(wVersion.getText()) &&
                                   !v.getName().equalsIgnoreCase(wFromdate.getText()) &&
                                   !v.getName().equalsIgnoreCase(wTodate.getText())
                                   )
                               {
                                   return true;
                               }
                               return false;
                           }
                       }
                   );
			}
		}
		catch(KettleException e)
		{
			MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR );
			mb.setText(Messages.getString("DimensionLookupDialog.ErrorOccurred.DialogTitle")); //$NON-NLS-1$
			mb.setMessage(Messages.getString("DimensionLookupDialog.ErrorOccurred.DialogMessage")+Const.CR+e.getMessage()); //$NON-NLS-1$
			mb.open();
		}
		finally
		{
			db.disconnect();
		}
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:53,代码来源:DimensionLookupDialog.java

示例10: getSQLStatements

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev)
{
    SQLStatement retval = new SQLStatement(stepMeta.getName(), databaseMeta, null); // default: nothing to do!

    if (databaseMeta!=null)
    {
        if (prev!=null && prev.size()>0)
        {
            if (!Const.isEmpty(tablename))
            {
                Database db = new Database(loggingObject, databaseMeta);
                db.shareVariablesWith(transMeta);
                try
                {
                    db.connect();
                    
                    String schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
                    String cr_table = db.getDDL(schemaTable, prev);
                    
                    // Squeeze in the VECTORWISE col store clause...
                    // TODO: move this to the database dialog and make it user configurable.
                    //
                    String VW_CLAUSE="WITH STRUCTURE=VECTORWISE";
                    
                    if (cr_table.toUpperCase().contains("CREATE TABLE")) {
                      int scIndex = cr_table.indexOf(';');
                      if (scIndex<0) {
                        cr_table +=VW_CLAUSE;
                      } else {
                        cr_table = cr_table.substring(0, scIndex)+ VW_CLAUSE + cr_table.substring(scIndex);
                      }
                    }
                    
                    // Empty string means: nothing to do: set it to null...
                    if (cr_table==null || cr_table.length()==0) cr_table=null;
                    
                    retval.setSQL(cr_table);
                }
                catch(KettleDatabaseException dbe)
                {
                    retval.setError(BaseMessages.getString(PKG, "IngresVectorWiseLoaderMeta.Error.ErrorConnecting", dbe.getMessage()));
                }
                finally
                {
                    db.disconnect();
                }
            }
            else
            {
                retval.setError(BaseMessages.getString(PKG, "IngresVectorWiseLoaderMeta.Error.NoTable"));
            }
        }
        else
        {
            retval.setError(BaseMessages.getString(PKG, "IngresVectorWiseLoaderMeta.Error.NoInput"));
        }
    }
    else
    {
        retval.setError(BaseMessages.getString(PKG, "IngresVectorWiseLoaderMeta.Error.NoConnection"));
    }

    return retval;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:65,代码来源:IngresVectorwiseLoaderMeta.java

示例11: getSQLStatements

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev) throws KettleStepException
{
	SQLStatement retval = new SQLStatement(stepMeta.getName(), databaseMeta, null); // default: nothing to do!

	if (databaseMeta!=null)
	{
		if (prev!=null && prev.size()>0)
		{
               // Copy the row
               RowMetaInterface tableFields = new RowMeta();

               // Now change the field names
               for (int i=0;i<fieldTable.length;i++)
               {
                   ValueMetaInterface v = prev.searchValueMeta(fieldStream[i]);
                   if (v!=null)
                   {
                       ValueMetaInterface tableField = v.clone();
                       tableField.setName(fieldTable[i]);
                       tableFields.addValueMeta(tableField);
                   }
                   else
                   {
                       throw new KettleStepException("Unable to find field ["+fieldStream[i]+"] in the input rows");
                   }
               }

			if (!Const.isEmpty(tableName))
			{
                   Database db = new Database(loggingObject, databaseMeta);
                   db.shareVariablesWith(transMeta);
				try
				{
					db.connect();

                       String schemaTable = databaseMeta.getQuotedSchemaTableCombination(transMeta.environmentSubstitute(schemaName), 
                       		                                                          transMeta.environmentSubstitute(tableName));                        
					String sql = db.getDDL(schemaTable,
												tableFields,
												null,
												false,
												null,
												true
												);

					if (Const.isEmpty(sql)) {
					  retval.setSQL(null); 
					} else {
					  retval.setSQL(sql);
					}
				}
				catch(KettleException e)
				{
					retval.setError(BaseMessages.getString(PKG, "LucidDBBulkLoaderMeta.GetSQL.ErrorOccurred")+e.getMessage()); //$NON-NLS-1$
				}
			}
			else
			{
				retval.setError(BaseMessages.getString(PKG, "LucidDBBulkLoaderMeta.GetSQL.NoTableDefinedOnConnection")); //$NON-NLS-1$
			}
		}
		else
		{
			retval.setError(BaseMessages.getString(PKG, "LucidDBBulkLoaderMeta.GetSQL.NotReceivingAnyFields")); //$NON-NLS-1$
		}
	}
	else
	{
		retval.setError(BaseMessages.getString(PKG, "LucidDBBulkLoaderMeta.GetSQL.NoConnectionDefined")); //$NON-NLS-1$
	}

	return retval;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:74,代码来源:LucidDBBulkLoaderMeta.java

示例12: getSchemaNames

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
private void getSchemaNames()
{
	if(wSchema.isDisposed()) return; 
	DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
	if (databaseMeta!=null)
	{
		Database database = new Database(loggingObject, databaseMeta);
		try
		{
			database.connect();
			String schemas[] = database.getSchemas();
			
			if (null != schemas && schemas.length>0) {
				schemas=Const.sortStrings(schemas);	
				EnterSelectionDialog dialog = new EnterSelectionDialog(shell, schemas, 
						BaseMessages.getString(PKG, "AddSequenceDialog.SelectSequence.Title",wConnection.getText()), 
						BaseMessages.getString(PKG, "AddSequenceDialog.SelectSequence.Message"));
				String d=dialog.open();
				if (d!=null) 
				{
					wSchema.setText(Const.NVL(d.toString(), ""));
				}

			}else
			{
				MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR );
				mb.setMessage(BaseMessages.getString(PKG,"AddSequenceDialog.NoSchema.Message"));
				mb.setText(BaseMessages.getString(PKG,"AddSequenceDialog.NoSchema.Title"));
				mb.open(); 
			}
		}
		catch(Exception e)
		{
			new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), 
					BaseMessages.getString(PKG, "AddSequenceDialog.ErrorGettingSchemas"), e);
		}
		finally
		{
			if(database!=null) 
			{
				database.disconnect();
				database=null;
			}
		}
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:47,代码来源:AddSequenceDialog.java

示例13: getLastExecutionResult

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public static String getLastExecutionResult(LogChannelInterface log, LoggingObjectInterface parentObject, ReportSubjectLocation filename) throws KettleException {

	LogTableInterface logTable=null;
	if (filename.isTransformation()) {
		TransMeta transMeta = TransformationInformation.getInstance().getTransMeta(filename);
		logTable = transMeta.getTransLogTable();
	} else {
		JobMeta jobMeta  = JobInformation.getInstance().getJobMeta(filename);
		logTable = jobMeta.getJobLogTable();
	}
	if (logTable!=null && logTable.isDefined()) {
		DatabaseMeta dbMeta = logTable.getDatabaseMeta();
		Database database = new Database(parentObject, dbMeta);
		try {
			database.connect();
			String sql="SELECT ";
			sql+=dbMeta.quoteField(logTable.getStatusField().getFieldName())+", ";
			sql+=dbMeta.quoteField(logTable.getLogDateField().getFieldName())+", ";
			sql+=dbMeta.quoteField(logTable.getErrorsField().getFieldName())+"";
			sql+=" FROM ";
			sql+=dbMeta.getQuotedSchemaTableCombination(logTable.getSchemaName(), logTable.getTableName());
			sql+=" ORDER BY "+dbMeta.quoteField(logTable.getLogDateField().getFieldName())+" DESC";
			
			RowMetaAndData oneRow = database.getOneRow(sql);
			String status = oneRow.getString(0, "?");
			Date date = oneRow.getDate(1, null);
			Long nrErrors = oneRow.getInteger(2);
			
			String evaluation;
			if (status.equalsIgnoreCase(LogStatus.END.getStatus())) {
				evaluation = "Ended";
			} else if (status.equalsIgnoreCase(LogStatus.START.getStatus())) {
				evaluation = "Started";
			} else if (status.equalsIgnoreCase(LogStatus.STOP.getStatus())) {
				evaluation = "Stopped";
			} else if (status.equalsIgnoreCase(LogStatus.RUNNING.getStatus())) {
				evaluation = "Running";
			} else if (status.equalsIgnoreCase(LogStatus.PAUSED.getStatus())) {
				evaluation = "Paused";
			} else if (status.equalsIgnoreCase(LogStatus.ERROR.getStatus())) {
				evaluation = "Failed";
			} else {
				evaluation = "Unknown";
			}
			if (nrErrors>0) {
				evaluation+=" with errors";
			} else {
				evaluation+=" with success";
			}
			
			return evaluation+" at "+XMLHandler.date2string(date);
			
		} catch(Exception e) {
			log.logBasic("Unable to get logging information from log table"+logTable);
		} finally {
			database.disconnect();
		}
	}
	return null;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:61,代码来源:KettleFileTableModel.java

示例14: getDDLForOther

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public void getDDLForOther(String tableName)
{
       if (databases!=null)
       {
   		Database db = new Database(dbMeta);
   		try
   		{
   			db.connect();
   			
   			RowMetaInterface r = db.getTableFields(tableName);
   
   			// Now select the other connection...
               
               // Only take non-SAP R/3 connections....
               List<DatabaseMeta> dbs = new ArrayList<DatabaseMeta>();
               for (int i=0;i<databases.size();i++) 
                   if ((databases.get(i)).getDatabaseType()!=DatabaseMeta.TYPE_DATABASE_SAPR3) dbs.add(databases.get(i));
               
               String conn[] = new String[dbs.size()];
   			for (int i=0;i<conn.length;i++) conn[i] = (dbs.get(i)).getName();
   			
   			EnterSelectionDialog esd = new EnterSelectionDialog(shell, conn, Messages.getString("DatabaseExplorerDialog.TargetDatabase.Title"),
                   Messages.getString("DatabaseExplorerDialog.TargetDatabase.Message"));
   			String target = esd.open();
   			if (target!=null)
   			{
   				DatabaseMeta targetdbi = DatabaseMeta.findDatabase(dbs, target);
   				Database targetdb = new Database(targetdbi);
   
   				String sql = targetdb.getCreateTableStatement(tableName, r, null, false, null, true);
   				SQLEditor se = new SQLEditor(shell, SWT.NONE, dbMeta, dbcache, sql);
   				se.open();
   			}
   		}
   		catch(KettleDatabaseException dbe)
   		{
   			new ErrorDialog(shell, Messages.getString("Dialog.Error.Header"),
                   Messages.getString("DatabaseExplorerDialog.Error.GenDDL"), dbe);
   		}
   		finally
   		{
   			db.disconnect();
   		}
       }
       else
       {
           MessageBox mb = new MessageBox(shell, SWT.NONE | SWT.ICON_INFORMATION);
           mb.setMessage(Messages.getString("DatabaseExplorerDialog.NoConnectionsKnown.Message"));
           mb.setText(Messages.getString("DatabaseExplorerDialog.NoConnectionsKnown.Title"));
           mb.open();
       }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:53,代码来源:DatabaseExplorerDialog.java

示例15: getRequiredFields

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public RowMetaInterface getRequiredFields(VariableSpace space) throws KettleException
{
	String realTableName = space.environmentSubstitute(tableName);
	String realSchemaName = space.environmentSubstitute(schemaName);

    if (databaseMeta!=null)
    {
        Database db = new Database(databaseMeta);
        try
        {
            db.connect();

            if (!Const.isEmpty(realTableName))
            {
                String schemaTable = databaseMeta.getQuotedSchemaTableCombination(realSchemaName, realTableName);

                // Check if this table exists...
                if (db.checkTableExists(schemaTable))
                {
                    return db.getTableFields(schemaTable);
                }
                else
                {
                    throw new KettleException(Messages.getString("LucidDBBulkLoaderMeta.Exception.TableNotFound"));
                }
            }
            else
            {
                throw new KettleException(Messages.getString("LucidDBBulkLoaderMeta.Exception.TableNotSpecified"));
            }
        }
        catch(Exception e)
        {
            throw new KettleException(Messages.getString("LucidDBBulkLoaderMeta.Exception.ErrorGettingFields"), e);
        }
        finally
        {
            db.disconnect();
        }
    }
    else
    {
        throw new KettleException(Messages.getString("LucidDBBulkLoaderMeta.Exception.ConnectionNotDefined"));
    }

}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:47,代码来源:LucidDBBulkLoaderMeta.java


注:本文中的org.pentaho.di.core.database.Database.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。