本文整理汇总了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 );
}
}
示例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 );
}
}
示例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 );
}
}