本文整理汇总了Java中org.pentaho.di.core.database.util.DatabaseUtil类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseUtil类的具体用法?Java DatabaseUtil怎么用?Java DatabaseUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseUtil类属于org.pentaho.di.core.database.util包,在下文中一共展示了DatabaseUtil类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: use
import org.pentaho.di.core.database.util.DatabaseUtil; //导入依赖的package包/类
/**
* 获取数据库操作对象 <br/>
* @author jingma
* @param dbCode
* @return
*/
public static Db use(String dbCode) {
try {
DataSource dataSource = ( new DatabaseUtil() ).getNamedDataSource( dbCode );
return new Db(dataSource,dbCode);
} catch (KettleException e) {
log.error("获取数据库失败:"+dbCode, e);
}
return null;
}
开发者ID:majinju,项目名称:KettleEasyExpand,代码行数:16,代码来源:Db.java
示例4: 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
示例5: openQuery
import org.pentaho.di.core.database.util.DatabaseUtil; //导入依赖的package包/类
@SuppressWarnings( "deprecation" )
public void openQuery() throws KettleDatabaseException {
connection = null;
String realRole = space.environmentSubstitute( role );
if ( databaseMeta.getAccessType() == DatabaseMeta.TYPE_ACCESS_JNDI ) {
DataSource dataSource = ( new DatabaseUtil() ).getNamedDataSource( databaseMeta.getDatabaseName() );
mondrian.olap.Util.PropertyList propList = new mondrian.olap.Util.PropertyList();
propList.put( "Provider", "mondrian" );
propList.put( "Catalog", space.environmentSubstitute( catalog ) );
if ( !Utils.isEmpty( realRole ) ) {
propList.put( "Role", realRole );
}
connection = DriverManager.getConnection( propList, null, dataSource );
} else {
String connectString =
"Provider=mondrian;"
+ "Jdbc='" + space.environmentSubstitute( databaseMeta.getURL() ) + "';" + "Catalog='"
+ space.environmentSubstitute( catalog ) + "';" + "JdbcDrivers="
+ space.environmentSubstitute( databaseMeta.getDriverClass() ) + ";";
if ( !Utils.isEmpty( databaseMeta.getUsername() ) ) {
connectString += "JdbcUser=" + space.environmentSubstitute( databaseMeta.getUsername() ) + ";";
}
String password = databaseMeta.getPassword();
if ( !Utils.isEmpty( password ) ) {
String realPassword = Utils.resolvePassword( space, password );
connectString += "JdbcPassword=" + space.environmentSubstitute( realPassword ) + ";";
}
if ( !Utils.isEmpty( realRole ) ) {
connectString += "Role=" + realRole + ";";
}
connection = DriverManager.getConnection( connectString, null );
}
query = connection.parseQuery( queryString );
result = connection.execute( query );
}
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:46,代码来源:MondrianHelper.java
注:本文中的org.pentaho.di.core.database.util.DatabaseUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论