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


Java DatabaseUtil.closeSilently方法代码示例

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


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

示例1: testPreparedStatementsProperty

import org.pentaho.di.core.database.util.DatabaseUtil; //导入方法依赖的package包/类
@Test
public void testPreparedStatementsProperty() throws Exception {
  Connection conn = null;
  PreparedStatement[] ps = new PreparedStatement[ 3 ];
  try {
    DatabaseMeta dbMeta = new DatabaseMeta( "testPreparedStatements", "H2", "JDBC", null, "mem:test", null, "SA", "" );
    dbMeta.setConnectionPoolingProperties( dsProps );
    conn = ConnectionPoolUtil.getConnection( logChannelInterface, dbMeta, "part1", INITIAL_POOL_SIZE, MAX_ACTIVE );
    ps[ 0 ] = conn.prepareStatement( VALIDATION_QUERY );
    ps[ 1 ] = conn.prepareStatement( VALIDATION_QUERY );
    boolean failed = false;
    try {
      ps[ 2 ] = conn.prepareStatement( VALIDATION_QUERY );
    } catch ( Exception e ) {
      failed = true;
    }
    assertTrue( "Properties 'poolPreparedStatements' or 'maxOpenPreparedStatements' don't work", failed );
  } finally {
    DatabaseUtil.closeSilently( ps );
    DatabaseUtil.closeSilently( conn );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:23,代码来源:ConnectionPoolUtilIntegrationIT.java

示例2: testMaxActiveProperty

import org.pentaho.di.core.database.util.DatabaseUtil; //导入方法依赖的package包/类
@Test( timeout = 6000 )
public void testMaxActiveProperty() throws Exception {
  Connection[] c = new Connection[ 3 ];
  DatabaseMeta dbMeta = new DatabaseMeta( "testPreparedStatements", "H2", "JDBC", null, "mem:test", null, "SA", "" );
  dbMeta.setConnectionPoolingProperties( dsProps );
  try {
    c[ 0 ] = ConnectionPoolUtil.getConnection( logChannelInterface, dbMeta, "part1", INITIAL_POOL_SIZE, MAX_ACTIVE );
    c[ 1 ] = ConnectionPoolUtil.getConnection( logChannelInterface, dbMeta, "part1", INITIAL_POOL_SIZE, MAX_ACTIVE );
    long startTime = System.currentTimeMillis();
    try {
      // this must wait a bit and throw an exception
      c[ 2 ] = ConnectionPoolUtil.getConnection( logChannelInterface, dbMeta, "part1", INITIAL_POOL_SIZE, MAX_ACTIVE );
    } catch ( SQLException e ) {
      long waitedTime = System.currentTimeMillis() - startTime;
      assertFalse( "Waited < maxWait", waitedTime < MAX_WAIT_TIME );
    }
  } finally {
    DatabaseUtil.closeSilently( c );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:21,代码来源:ConnectionPoolUtilIntegrationIT.java

示例3: testDataSource

import org.pentaho.di.core.database.util.DatabaseUtil; //导入方法依赖的package包/类
/**
 * This method verifies that it's possible to get connection fron a datasource
 *
 * @param ds
 * @throws KettleDatabaseException
 */
private static void testDataSource( DataSource ds ) throws KettleDatabaseException {
  Connection conn = null;
  try {
    conn = ds.getConnection();
  } catch ( Throwable e ) {
    throw new KettleDatabaseException( BaseMessages.getString( PKG,
        "Database.UnableToPreLoadConnectionToConnectionPool.Exception" ), e );
  } finally {
    DatabaseUtil.closeSilently( conn );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:18,代码来源:ConnectionPoolUtil.java


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