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


Java KettleDatabaseBatchException类代码示例

本文整理汇总了Java中org.pentaho.di.core.exception.KettleDatabaseBatchException的典型用法代码示例。如果您正苦于以下问题:Java KettleDatabaseBatchException类的具体用法?Java KettleDatabaseBatchException怎么用?Java KettleDatabaseBatchException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KettleDatabaseBatchException类属于org.pentaho.di.core.exception包,在下文中一共展示了KettleDatabaseBatchException类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createKettleDatabaseBatchException

import org.pentaho.di.core.exception.KettleDatabaseBatchException; //导入依赖的package包/类
public static KettleDatabaseBatchException createKettleDatabaseBatchException( String message, SQLException ex ) {
  KettleDatabaseBatchException kdbe = new KettleDatabaseBatchException( message, ex );
  if ( ex instanceof BatchUpdateException ) {
    kdbe.setUpdateCounts( ( (BatchUpdateException) ex ).getUpdateCounts() );
  } else {
    // Null update count forces rollback of batch
    kdbe.setUpdateCounts( null );
  }
  List<Exception> exceptions = new ArrayList<Exception>();
  SQLException nextException = ex.getNextException();
  SQLException oldException = null;

  // This construction is specifically done for some JDBC drivers, these
  // drivers
  // always return the same exception on getNextException() (and thus go
  // into an infinite loop).
  // So it's not "equals" but != (comments from Sven Boden).
  while ( ( nextException != null ) && ( oldException != nextException ) ) {
    exceptions.add( nextException );
    oldException = nextException;
    nextException = nextException.getNextException();
  }
  kdbe.setExceptionsList( exceptions );
  return kdbe;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:26,代码来源:Database.java

示例2: testInsertRowWithBatchAlwaysThrowsKettleBatchException

import org.pentaho.di.core.exception.KettleDatabaseBatchException; //导入依赖的package包/类
@Test( expected = KettleDatabaseBatchException.class )
public void testInsertRowWithBatchAlwaysThrowsKettleBatchException() throws KettleDatabaseException, SQLException {
  DatabaseMeta mockDatabaseMeta = mock( DatabaseMeta.class );
  when( mockDatabaseMeta.supportsBatchUpdates() ).thenReturn( true );

  DatabaseMetaData mockDatabaseMetaData = mock( DatabaseMetaData.class );
  when( mockDatabaseMetaData.supportsBatchUpdates() ).thenReturn( true );
  Connection mockConnection = mockConnection( mockDatabaseMetaData );

  PreparedStatement ps = mock( PreparedStatement.class );
  when( ps.executeBatch() ).thenThrow( new SQLException() );

  Database database = new Database( mockLogger(), mockDatabaseMeta );
  database.setCommit( 1 );
  database.setConnection( mockConnection );
  database.insertRow( ps, true, true );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:18,代码来源:DatabaseUnitTest.java

示例3: testInsertRowWithoutBatchDoesntThrowKettleBatchException

import org.pentaho.di.core.exception.KettleDatabaseBatchException; //导入依赖的package包/类
@Test( expected = KettleDatabaseException.class )
public void testInsertRowWithoutBatchDoesntThrowKettleBatchException() throws KettleDatabaseException, SQLException {
  DatabaseMeta mockDatabaseMeta = mock( DatabaseMeta.class );
  when( mockDatabaseMeta.supportsBatchUpdates() ).thenReturn( true );

  DatabaseMetaData mockDatabaseMetaData = mock( DatabaseMetaData.class );
  when( mockDatabaseMetaData.supportsBatchUpdates() ).thenReturn( true );
  Connection mockConnection = mockConnection( mockDatabaseMetaData );

  PreparedStatement ps = mock( PreparedStatement.class );
  when( ps.executeUpdate() ).thenThrow( new SQLException() );

  Database database = new Database( mockLogger(), mockDatabaseMeta );
  database.setConnection( mockConnection );
  try {
    database.insertRow( ps, true, true );
  } catch ( KettleDatabaseBatchException e ) {
    // noop
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:21,代码来源:DatabaseUnitTest.java

示例4: testEmptyAndCommitWithBatchAlwaysThrowsKettleBatchException

import org.pentaho.di.core.exception.KettleDatabaseBatchException; //导入依赖的package包/类
@Test( expected = KettleDatabaseBatchException.class )
public void testEmptyAndCommitWithBatchAlwaysThrowsKettleBatchException() throws KettleDatabaseException,
  SQLException {
  DatabaseMeta mockDatabaseMeta = mock( DatabaseMeta.class );
  when( mockDatabaseMeta.supportsBatchUpdates() ).thenReturn( true );

  DatabaseMetaData mockDatabaseMetaData = mock( DatabaseMetaData.class );
  when( mockDatabaseMetaData.supportsBatchUpdates() ).thenReturn( true );
  Connection mockConnection = mockConnection( mockDatabaseMetaData );

  PreparedStatement ps = mock( PreparedStatement.class );
  when( ps.executeBatch() ).thenThrow( new SQLException() );

  Database database = new Database( mockLogger(), mockDatabaseMeta );
  database.setCommit( 1 );
  database.setConnection( mockConnection );
  database.emptyAndCommit( ps, true, 1 );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:19,代码来源:DatabaseUnitTest.java

示例5: testEmptyAndCommitWithoutBatchDoesntThrowKettleBatchException

import org.pentaho.di.core.exception.KettleDatabaseBatchException; //导入依赖的package包/类
@Test( expected = KettleDatabaseException.class )
public void testEmptyAndCommitWithoutBatchDoesntThrowKettleBatchException()
  throws KettleDatabaseException, SQLException {
  DatabaseMeta mockDatabaseMeta = mock( DatabaseMeta.class );
  when( mockDatabaseMeta.supportsBatchUpdates() ).thenReturn( true );

  DatabaseMetaData mockDatabaseMetaData = mock( DatabaseMetaData.class );
  when( mockDatabaseMetaData.supportsBatchUpdates() ).thenReturn( true );
  Connection mockConnection = mockConnection( mockDatabaseMetaData );

  PreparedStatement ps = mock( PreparedStatement.class );
  doThrow( new SQLException() ).when( ps ).close();

  Database database = new Database( mockLogger(), mockDatabaseMeta );
  database.setConnection( mockConnection );
  try {
    database.emptyAndCommit( ps, true, 1 );
  } catch ( KettleDatabaseBatchException e ) {
    // noop
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:22,代码来源:DatabaseUnitTest.java

示例6: testInsertFinishedWithBatchAlwaysThrowsKettleBatchException

import org.pentaho.di.core.exception.KettleDatabaseBatchException; //导入依赖的package包/类
@SuppressWarnings( "deprecation" )
@Test( expected = KettleDatabaseBatchException.class )
public void testInsertFinishedWithBatchAlwaysThrowsKettleBatchException() throws KettleDatabaseException,
  SQLException {
  DatabaseMeta mockDatabaseMeta = mock( DatabaseMeta.class );
  when( mockDatabaseMeta.supportsBatchUpdates() ).thenReturn( true );

  DatabaseMetaData mockDatabaseMetaData = mock( DatabaseMetaData.class );
  when( mockDatabaseMetaData.supportsBatchUpdates() ).thenReturn( true );
  Connection mockConnection = mockConnection( mockDatabaseMetaData );

  PreparedStatement ps = mock( PreparedStatement.class );
  when( ps.executeBatch() ).thenThrow( new SQLException() );

  Database database = new Database( mockLogger(), mockDatabaseMeta );
  database.setCommit( 1 );
  database.setConnection( mockConnection );
  database.insertFinished( ps, true );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:20,代码来源:DatabaseUnitTest.java

示例7: testInsertFinishedWithoutBatchDoesntThrowKettleBatchException

import org.pentaho.di.core.exception.KettleDatabaseBatchException; //导入依赖的package包/类
@SuppressWarnings( "deprecation" )
@Test( expected = KettleDatabaseException.class )
public void testInsertFinishedWithoutBatchDoesntThrowKettleBatchException()
  throws KettleDatabaseException, SQLException {
  DatabaseMeta mockDatabaseMeta = mock( DatabaseMeta.class );
  when( mockDatabaseMeta.supportsBatchUpdates() ).thenReturn( true );

  DatabaseMetaData mockDatabaseMetaData = mock( DatabaseMetaData.class );
  when( mockDatabaseMetaData.supportsBatchUpdates() ).thenReturn( true );
  Connection mockConnection = mockConnection( mockDatabaseMetaData );

  PreparedStatement ps = mock( PreparedStatement.class );
  doThrow( new SQLException() ).when( ps ).close();

  Database database = new Database( mockLogger(), mockDatabaseMeta );
  database.setConnection( mockConnection );
  try {
    database.insertFinished( ps, true );
  } catch ( KettleDatabaseBatchException e ) {
    // noop
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:23,代码来源:DatabaseUnitTest.java


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