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

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

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

Database.normalConnect介绍

[英]Open the database connection. The algorithm is:

  1. If databaseMeta.getAccessType() returns DatabaseMeta.TYPE_ACCESS_JNDI, then the connection's datasource is looked up in JNDI
  2. If databaseMeta.isUsingConnectionPool(), then the connection's datasource is looked up in the pool
  3. otherwise, the connection is established via java.sql.DriverManager
    [中]打开数据库连接。算法是:
    1.如果databaseMeta.getAccessType()返回DatabaseMeta.TYPE_ACCESS_JNDI,则在JNDI中查找连接的数据源
    1.如果databaseMeta.isUsingConnectionPool(),则在池中查找连接的数据源
    1.否则,通过java建立连接。sql。驱动管理器

代码示例

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

private synchronized void shareConnectionWith( String partitionId, Database anotherDb )
 throws KettleDatabaseException {
 // inside synchronized block we can increment 'opened' directly
 this.opened++;
 if ( this.connection == null ) {
  normalConnect( partitionId );
  this.copy = this.opened;
  // If we have a connection group or transaction ID, disable auto commit!
  //
  setAutoCommit( false );
 }
 anotherDb.connection = this.connection;
 anotherDb.copy = this.opened;
}

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

private Database createVirtualDb( DatabaseMeta meta ) throws Exception {
 ResultSet rs = mock( ResultSet.class );
 when( rs.getMetaData() ).thenReturn( mock( ResultSetMetaData.class ) );
 PreparedStatement ps = mock( PreparedStatement.class );
 when( ps.executeQuery() ).thenReturn( rs );
 Connection connection = mock( Connection.class );
 when( connection.prepareStatement( anyString() ) ).thenReturn( ps );
 Database db = new Database( mock( LoggingObjectInterface.class ), meta );
 db.setConnection( connection );
 db = spy( db );
 doNothing().when( db ).normalConnect( anyString() );
 ValueMetaInterface binary = new ValueMetaString( BINARY_FIELD );
 binary.setStorageType( ValueMetaInterface.STORAGE_TYPE_BINARY_STRING );
 ValueMetaInterface id = new ValueMetaInteger( ID_FIELD );
 RowMetaInterface metaByQuerying = new RowMeta();
 metaByQuerying.addValueMeta( binary );
 metaByQuerying.addValueMeta( id );
 doReturn( metaByQuerying ).when( db ).getTableFields( anyString() );
 doReturn( metaByQuerying ).when( db ).getTableFieldsMeta( anyString(), anyString() );
 return db;
}

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

} else {
 normalConnect( partitionId );

相关文章

微信公众号

最新文章

更多