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

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

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

Database.truncateTable介绍

暂无

代码示例

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

  1. @Test
  2. public void testTruncateTable_off() throws Exception {
  3. tableOutputSpy.truncateTable();
  4. verify( db, never() ).truncateTable( anyString(), anyString() );
  5. }

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

  1. @Test
  2. public void testTruncateTable_on() throws Exception {
  3. when( tableOutputMeta.truncateTable() ).thenReturn( true );
  4. when( tableOutputSpy.getCopy() ).thenReturn( 0 );
  5. when( tableOutputSpy.getUniqueStepNrAcrossSlaves() ).thenReturn( 0 );
  6. tableOutputSpy.truncateTable();
  7. verify( db ).truncateTable( anyString(), anyString() );
  8. }

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

  1. @Test
  2. public void testTruncateTable_on_PartitionId() throws Exception {
  3. when( tableOutputMeta.truncateTable() ).thenReturn( true );
  4. when( tableOutputSpy.getCopy() ).thenReturn( 1 );
  5. when( tableOutputSpy.getUniqueStepNrAcrossSlaves() ).thenReturn( 0 );
  6. when( tableOutputSpy.getPartitionID() ).thenReturn( "partition id" );
  7. tableOutputSpy.truncateTable();
  8. verify( db ).truncateTable( anyString(), anyString() );
  9. }

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

  1. private boolean truncateTables( String tablename, String schemaname, Database db ) {
  2. boolean retval = false;
  3. try {
  4. // check if table exists!
  5. if ( db.checkTableExists( schemaname, tablename ) ) {
  6. if ( !Utils.isEmpty( schemaname ) ) {
  7. db.truncateTable( schemaname, tablename );
  8. } else {
  9. db.truncateTable( tablename );
  10. }
  11. if ( log.isDetailed() ) {
  12. logDetailed( BaseMessages.getString( PKG, "JobEntryTruncateTables.Log.TableTruncated", tablename ) );
  13. }
  14. retval = true;
  15. } else {
  16. logError( BaseMessages.getString( PKG, "JobEntryTruncateTables.Error.CanNotFindTable", tablename ) );
  17. }
  18. } catch ( Exception e ) {
  19. logError( BaseMessages.getString( PKG, "JobEntryTruncateTables.Error.CanNotTruncateTables", tablename, e
  20. .toString() ) );
  21. }
  22. return retval;
  23. }

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

  1. @Override
  2. public boolean truncateTable() {
  3. TableOutputMeta meta = getMeta();
  4. TableOutputData data = getData();
  5. try {
  6. data.db.truncateTable( environmentSubstitute( meta.getSchemaName() ), environmentSubstitute( meta
  7. .getTableName() ) );
  8. util.updateMetadata( meta, -1 );
  9. return true;
  10. } catch ( KettleDatabaseException e ) {
  11. message = "Could not truncate table: " + meta.getTableName();
  12. logError( message, e );
  13. }
  14. return false;
  15. }

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

  1. void truncateTable() throws KettleDatabaseException {
  2. if ( !meta.isPartitioningEnabled() && !meta.isTableNameInField() ) {
  3. // Only the first one truncates in a non-partitioned step copy
  4. //
  5. if ( meta.truncateTable()
  6. && ( ( getCopy() == 0 && getUniqueStepNrAcrossSlaves() == 0 ) || !Utils.isEmpty( getPartitionID() ) ) ) {
  7. data.db.truncateTable( environmentSubstitute( meta.getSchemaName() ), environmentSubstitute( meta
  8. .getTableName() ) );
  9. }
  10. }
  11. }

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

  1. /**
  2. * Execute fastload.
  3. *
  4. * @throws KettleException
  5. * ...
  6. */
  7. public void execute() throws KettleException {
  8. if ( this.meta.getTruncateTable().getValue() ) {
  9. Database db = new Database( this, this.meta.getDbMeta() );
  10. db.connect();
  11. db.truncateTable( this.meta.getTargetTable().getValue() );
  12. db.commit();
  13. db.disconnect();
  14. }
  15. startFastLoad();
  16. if ( this.meta.getUseControlFile().getValue() ) {
  17. this.invokeLoadingControlFile();
  18. } else {
  19. this.invokeLoadingCommand();
  20. }
  21. }

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

  1. try {
  2. database.connect();
  3. database.truncateTable( schemaTable );
  4. } catch ( Exception e ) {
  5. new ErrorDialog( jobGraph.getShell(),

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

  1. try {
  2. database.connect();
  3. database.truncateTable( schemaTable );
  4. } catch ( Exception e ) {
  5. new ErrorDialog( transGraph.getShell(),

相关文章