org.pentaho.di.core.database.Database.shareVariablesWith()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中org.pentaho.di.core.database.Database.shareVariablesWith()方法的一些代码示例,展示了Database.shareVariablesWith()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database.shareVariablesWith()方法的具体详情如下:
包路径:org.pentaho.di.core.database.Database
类名称:Database
方法名:shareVariablesWith

Database.shareVariablesWith介绍

暂无

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

  1. protected void checkConnection() throws KettleDatabaseException {
  2. // check connection
  3. // connect and disconnect
  4. Database dbchecked = null;
  5. try {
  6. dbchecked = new Database( this, connection );
  7. dbchecked.shareVariablesWith( this );
  8. dbchecked.connect( parentJob.getTransactionId(), null );
  9. } finally {
  10. if ( dbchecked != null ) {
  11. dbchecked.disconnect();
  12. }
  13. }
  14. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. /**
  2. * Construct a new Database Connection
  3. *
  4. * @param databaseMeta The Database Connection Info to construct the connection with.
  5. */
  6. public Database( LoggingObjectInterface parentObject, DatabaseMeta databaseMeta ) {
  7. this.parentLoggingObject = parentObject;
  8. this.databaseMeta = databaseMeta;
  9. shareVariablesWith( databaseMeta );
  10. if ( parentObject instanceof VariableSpace ) {
  11. shareVariablesWith( (VariableSpace) parentObject );
  12. }
  13. log = new LogChannel( this, parentObject );
  14. this.containerObjectId = log.getContainerObjectId();
  15. this.logLevel = log.getLogLevel();
  16. if ( parentObject != null ) {
  17. log.setGatheringMetrics( parentObject.isGatheringMetrics() );
  18. }
  19. pstmt = null;
  20. rowMeta = null;
  21. dbmd = null;
  22. rowlimit = 0;
  23. written = 0;
  24. opened = copy = 0;
  25. if ( log.isDetailed() ) {
  26. log.logDetailed( "New database connection defined" );
  27. }
  28. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. /**
  2. * Construct a new Database Connection
  3. *
  4. * @param databaseMeta The Database Connection Info to construct the connection with.
  5. * @deprecated Please specify the parent object so that we can see which object is initiating a database connection
  6. */
  7. @Deprecated
  8. public Database( DatabaseMeta databaseMeta ) {
  9. this.parentLoggingObject = null;
  10. this.databaseMeta = databaseMeta;
  11. shareVariablesWith( databaseMeta );
  12. // In this case we don't have the parent object, so we don't know which
  13. // object makes the connection.
  14. // We also don't know what log level to attach to it, so we have to stick to
  15. // the default
  16. // As such, this constructor is @deprecated.
  17. //
  18. log = new LogChannel( this );
  19. logLevel = log.getLogLevel();
  20. containerObjectId = log.getContainerObjectId();
  21. pstmt = null;
  22. rowMeta = null;
  23. dbmd = null;
  24. rowlimit = 0;
  25. written = 0;
  26. opened = copy = 0;
  27. if ( log.isDetailed() ) {
  28. log.logDetailed( "New database connection defined" );
  29. }
  30. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. /**
  2. * {@inheritDoc}
  3. *
  4. * @see org.pentaho.di.trans.step.BaseStepMeta#getRequiredFields(org.pentaho.di.core.variables.VariableSpace)
  5. */
  6. @Override
  7. public RowMetaInterface getRequiredFields( final VariableSpace space ) throws KettleException {
  8. if ( !this.useControlFile.getValue() ) {
  9. final Database database = connectToDatabase();
  10. database.shareVariablesWith( space );
  11. RowMetaInterface fields =
  12. database.getTableFieldsMeta(
  13. StringUtils.EMPTY,
  14. space.environmentSubstitute( this.targetTable.getValue() ) );
  15. database.disconnect();
  16. if ( fields == null ) {
  17. throw new KettleException( MESSAGES.getString( "TeraFastMeta.Exception.TableNotFound" ) );
  18. }
  19. return fields;
  20. }
  21. return null;
  22. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. private void connectDatabase( Database database ) throws KettleDatabaseException {
  2. database.shareVariablesWith( this );
  3. if ( getTransMeta().isUsingUniqueConnections() ) {
  4. synchronized ( getTrans() ) {
  5. database.connect( getTrans().getTransactionId(), getPartitionID() );
  6. }
  7. } else {
  8. database.connect( getPartitionID() );
  9. }
  10. database.setCommit( 100 ); // we never get a commit, but it just turns off auto-commit.
  11. if ( log.isDetailed() ) {
  12. logDetailed( BaseMessages.getString( PKG, "DatabaseLookup.Log.ConnectedToDatabase" ) );
  13. }
  14. }
  15. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. /**
  2. * Writes step information to a step logging table (if one has been configured).
  3. *
  4. * @throws KettleException if any errors occur during logging
  5. */
  6. protected void writeStepLogInformation() throws KettleException {
  7. Database db = null;
  8. StepLogTable stepLogTable = getTransMeta().getStepLogTable();
  9. try {
  10. db = createDataBase( stepLogTable.getDatabaseMeta() );
  11. db.shareVariablesWith( this );
  12. db.connect();
  13. db.setCommit( logCommitSize );
  14. for ( StepMetaDataCombi combi : getSteps() ) {
  15. db.writeLogRecord( stepLogTable, LogStatus.START, combi, null );
  16. }
  17. db.cleanupLogRecords( stepLogTable );
  18. } catch ( Exception e ) {
  19. throw new KettleException( BaseMessages.getString( PKG,
  20. "Trans.Exception.UnableToWriteStepInformationToLogTable" ), e );
  21. } finally {
  22. disconnectDb( db );
  23. }
  24. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. /**
  2. * Writes information to Job Log table. Cleans old records, in case job is finished.
  3. */
  4. protected void writeLogTableInformation( JobLogTable jobLogTable, LogStatus status ) throws KettleJobException,
  5. KettleDatabaseException {
  6. boolean cleanLogRecords = status.equals( LogStatus.END );
  7. String tableName = jobLogTable.getActualTableName();
  8. DatabaseMeta logcon = jobLogTable.getDatabaseMeta();
  9. Database ldb = createDataBase( logcon );
  10. ldb.shareVariablesWith( this );
  11. try {
  12. ldb.connect();
  13. ldb.setCommit( logCommitSize );
  14. ldb.writeLogRecord( jobLogTable, status, this, null );
  15. if ( cleanLogRecords ) {
  16. ldb.cleanupLogRecords( jobLogTable );
  17. }
  18. } catch ( KettleDatabaseException dbe ) {
  19. addErrors( 1 );
  20. throw new KettleJobException( "Unable to end processing by writing log record to table " + tableName, dbe );
  21. } finally {
  22. if ( !ldb.isAutoCommit() ) {
  23. ldb.commitLog( true, jobLogTable );
  24. }
  25. ldb.disconnect();
  26. }
  27. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. @Override
  2. public SQLStatement getSQLStatements( TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
  3. Repository repository, IMetaStore metaStore ) {
  4. SQLStatement retval = new SQLStatement( stepMeta.getName(), database, null ); // default: nothing to do!
  5. if ( useDatabase ) {
  6. // Otherwise, don't bother!
  7. if ( database != null ) {
  8. Database db = new Database( loggingObject, database );
  9. db.shareVariablesWith( transMeta );
  10. try {
  11. db.connect();
  12. if ( !db.checkSequenceExists( schemaName, sequenceName ) ) {
  13. String cr_table = db.getCreateSequenceStatement( sequenceName, startAt, incrementBy, maxValue, true );
  14. retval.setSQL( cr_table );
  15. } else {
  16. retval.setSQL( null ); // Empty string means: nothing to do: set it to null...
  17. }
  18. } catch ( KettleException e ) {
  19. retval.setError( BaseMessages.getString( PKG, "AddSequenceMeta.ErrorMessage.UnableToConnectDB" )
  20. + Const.CR + e.getMessage() );
  21. } finally {
  22. db.disconnect();
  23. }
  24. } else {
  25. retval.setError( BaseMessages.getString( PKG, "AddSequenceMeta.ErrorMessage.NoConnectionDefined" ) );
  26. }
  27. }
  28. return retval;
  29. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. if ( !Utils.isEmpty( tableName ) ) {
  2. Database db = new Database( loggingObject, databaseMeta );
  3. db.shareVariablesWith( transMeta );
  4. try {
  5. db.connect();

代码示例来源:origin: pentaho/pentaho-kettle

  1. if ( !Utils.isEmpty( tablename ) ) {
  2. Database db = new Database( loggingObject, databaseMeta );
  3. db.shareVariablesWith( transMeta );
  4. try {
  5. db.connect();

代码示例来源:origin: pentaho/pentaho-kettle

  1. db.shareVariablesWith( transMeta );
  2. try {
  3. db.connect();

代码示例来源:origin: pentaho/pentaho-kettle

  1. /**
  2. * Write job entry log information.
  3. *
  4. * @throws KettleException
  5. * the kettle exception
  6. */
  7. protected void writeJobEntryLogInformation() throws KettleException {
  8. Database db = null;
  9. JobEntryLogTable jobEntryLogTable = getJobMeta().getJobEntryLogTable();
  10. try {
  11. db = createDataBase( jobEntryLogTable.getDatabaseMeta() );
  12. db.shareVariablesWith( this );
  13. db.connect();
  14. db.setCommit( logCommitSize );
  15. for ( JobEntryCopy copy : getJobMeta().getJobCopies() ) {
  16. db.writeLogRecord( jobEntryLogTable, LogStatus.START, copy, this );
  17. }
  18. db.cleanupLogRecords( jobEntryLogTable );
  19. } catch ( Exception e ) {
  20. throw new KettleException( BaseMessages.getString( PKG, "Job.Exception.UnableToJobEntryInformationToLogTable" ),
  21. e );
  22. } finally {
  23. if ( !db.isAutoCommit() ) {
  24. db.commitLog( true, jobEntryLogTable );
  25. }
  26. db.disconnect();
  27. }
  28. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. data.db.shareVariablesWith( this );
  2. try {
  3. if ( getTransMeta().isUsingUniqueConnections() ) {

代码示例来源:origin: pentaho/pentaho-kettle

  1. if ( databaseMeta != null ) {
  2. Database database = new Database( loggingObject, databaseMeta );
  3. database.shareVariablesWith( jobMeta );
  4. try {
  5. database.connect();

代码示例来源:origin: pentaho/pentaho-kettle

  1. if ( databaseMeta != null ) {
  2. Database database = new Database( loggingObject, databaseMeta );
  3. database.shareVariablesWith( transMeta );
  4. try {
  5. database.connect();

代码示例来源:origin: pentaho/pentaho-kettle

  1. public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {
  2. meta = (InsertUpdateMeta) smi;
  3. data = (InsertUpdateData) sdi;
  4. if ( super.init( smi, sdi ) ) {
  5. try {
  6. if ( meta.getDatabaseMeta() == null ) {
  7. logError( BaseMessages.getString( PKG, "InsertUpdate.Init.ConnectionMissing", getStepname() ) );
  8. return false;
  9. }
  10. data.db = new Database( this, meta.getDatabaseMeta() );
  11. data.db.shareVariablesWith( this );
  12. if ( getTransMeta().isUsingUniqueConnections() ) {
  13. synchronized ( getTrans() ) {
  14. data.db.connect( getTrans().getTransactionId(), getPartitionID() );
  15. }
  16. } else {
  17. data.db.connect( getPartitionID() );
  18. }
  19. data.db.setCommit( meta.getCommitSize( this ) );
  20. return true;
  21. } catch ( KettleException ke ) {
  22. logError( BaseMessages.getString( PKG, "InsertUpdate.Log.ErrorOccurredDuringStepInitialize" )
  23. + ke.getMessage() );
  24. }
  25. }
  26. return false;
  27. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. data.db.shareVariablesWith( this );
  2. try {
  3. if ( getTransMeta().isUsingUniqueConnections() ) {

代码示例来源:origin: pentaho/pentaho-kettle

  1. data.db.shareVariablesWith( this );
  2. try {
  3. if ( getTransMeta().isUsingUniqueConnections() ) {

代码示例来源:origin: pentaho/pentaho-kettle

  1. data.db.shareVariablesWith( this );
  2. try {
  3. if ( getTransMeta().isUsingUniqueConnections() ) {

代码示例来源:origin: pentaho/pentaho-kettle

  1. data.db.shareVariablesWith( this );
  2. if ( !Utils.isEmpty( meta.getSchemaname() ) ) {
  3. data.realSchemaname = environmentSubstitute( meta.getSchemaname() );

相关文章