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


Java DatabaseInterface类代码示例

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


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

示例1: addDatabases

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
public void addDatabases(ComboVar wConnection, Class<? extends DatabaseInterface> databaseType) {
for (int i = 0; i < transMeta.nrDatabases(); i++) {
    DatabaseMeta ci = transMeta.getDatabase(i);
    if (databaseType==null || ci.getDatabaseInterface().getClass().equals(databaseType)) {
 	  wConnection.add(ci.getName());
   }
}
//  Add the metaDBConnectionName if we have it 
//  and it is already not added to the list in wConnection.
if (!Const.isEmpty(input.getDbConnectionName())) {
 String[] arrayDatabaseList = wConnection.getItems();
 if (arrayDatabaseList == null) {
  List<String> databaseNameList = Arrays.asList(arrayDatabaseList);
  if (!databaseNameList.contains(input.getDbConnectionName())) {
   wConnection.add(input.getDbConnectionName());
  }
 }
}
}
 
开发者ID:bsspirit,项目名称:kettle-4.4.0-stable,代码行数:20,代码来源:MonetDBBulkLoaderDialog.java

示例2: publishDataSource

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
/**
 * Publishes a datasource to the current BI server
 * @param databaseMeta
 * @param update
 * @return
 * @throws KettleDatabaseException
 */
private boolean publishDataSource(DatabaseMeta databaseMeta, boolean update) throws KettleDatabaseException,
    ConnectionServiceException {

  // create a new connection object and populate it from the databaseMeta
  DatabaseConnection connection = new DatabaseConnection();
  DatabaseDialectService dds = new DatabaseDialectService();
  DatabaseTypeHelper dth = new DatabaseTypeHelper(dds.getDatabaseTypes());
  DatabaseInterface intf = databaseMeta.getDatabaseInterface();
  connection.setName(PublisherHelper.getBiServerCompatibleDatabaseName(databaseMeta.getName()));
  connection.setPassword(databaseMeta.getPassword());    
  connection.setUsername(databaseMeta.getUsername());   
  connection.setDatabaseName(intf.getDatabaseName());   
  connection.setDatabasePort(String.valueOf(intf.getAttributes().getProperty("PORT_NUMBER")));
  connection.setHostname(databaseMeta.getHostname());
  connection.setForcingIdentifiersToLowerCase("N".equals(intf.getAttributes().getProperty("FORCE_IDENTIFIERS_TO_LOWERCASE"))?false:true); 
  connection.setQuoteAllFields("N".equals(intf.getAttributes().getProperty("QUOTE_ALL_FIELDS"))?false:true);    
  connection.setAccessType(DatabaseAccessType.NATIVE);
  IDatabaseType driver = dth.getDatabaseTypeByShortName(intf.getPluginId());
  connection.setDatabaseType(driver);        
  return updateConnection(connection, update);
}
 
开发者ID:pentaho,项目名称:pdi-agile-bi-plugin,代码行数:29,代码来源:ModelServerPublish.java

示例3: getDatabaseInterface

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
public static DatabaseInterface getDatabaseInterface( String productName, DatabaseMeta databaseMeta ) {

    if ( productName == null ) {
      return null;
    }

    // special case to separate hive1 and hive2
    if ( productName.indexOf( "Apache Hive" ) >= 0 ) { //$NON-NLS-1$
      String hivePluginId = databaseMeta.getDatabaseInterface().getPluginId();
      switch ( hivePluginId ) {
        case "HIVE": //$NON-NLS-1$
        case "HIVE2": //$NON-NLS-1$
          productName = hivePluginId;
          break;
      }
    }
    return getDatabaseInterface( productName );
  }
 
开发者ID:pentaho,项目名称:pentaho-metadata,代码行数:19,代码来源:DatabaseMetaUtil.java

示例4: addDatabases

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
public void addDatabases( ComboVar wConnection, Class<? extends DatabaseInterface> databaseType ) {
  for ( int i = 0; i < transMeta.nrDatabases(); i++ ) {
    DatabaseMeta ci = transMeta.getDatabase( i );
    if ( databaseType == null || ci.getDatabaseInterface().getClass().equals( databaseType ) ) {
      wConnection.add( ci.getName() );
    }
  }
  // Add the metaDBConnectionName if we have it
  // and it is already not added to the list in wConnection.
  if ( !Utils.isEmpty( input.getDbConnectionName() ) ) {
    String[] arrayDatabaseList = wConnection.getItems();
    if ( arrayDatabaseList == null ) {
      List<String> databaseNameList = Arrays.asList();
      if ( !databaseNameList.contains( input.getDbConnectionName() ) ) {
        wConnection.add( input.getDbConnectionName() );
      }
    }
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:20,代码来源:MonetDBBulkLoaderDialog.java

示例5: getFragment

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
protected String getFragment( DatabaseInterface database, String dbName, String extension, String defaultFragment ) {
  String fragment;
  String ext = ( extension == null ? "" : extension );
  String databaseName = ( dbName == null ? "" : dbName );
  String defaultFrag = ( defaultFragment == null ? "" : defaultFragment );
  if ( database.getXulOverlayFile() != null ) {
    fragment = packagePath.concat( database.getXulOverlayFile() ).concat( ext );
  } else {
    fragment = packagePath.concat( databaseName ).concat( ext );
  }
  InputStream in = getClass().getClassLoader().getResourceAsStream( fragment.toLowerCase() );
  if ( in == null ) {
    fragment = packagePath.concat( defaultFrag );
  }
  return fragment;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:17,代码来源:FragmentHandler.java

示例6: pluginAdded

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
@Override
public void pluginAdded( Object serviceObject ) {
  PluginInterface plugin = (PluginInterface) serviceObject;
  String pluginName = plugin.getName();
  try {
    DatabaseInterface databaseInterface = (DatabaseInterface) registry.loadClass( plugin );
    databaseInterface.setPluginId( plugin.getIds()[0] );
    databaseInterface.setName( pluginName );
    databaseTypeAdded( pluginName, databaseInterface );
  } catch ( KettleException e ) {
    Throwable t = e;
    if ( e.getCause() != null ) {
      t = e.getCause();
    }
    System.out.println( "Could not create connection entry for "
      + pluginName + ".  " + t.getClass().getName() );
    LogChannel.GENERAL.logError( "Could not create connection entry for "
      + pluginName + ".  " + t.getClass().getName() );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:21,代码来源:DataHandler.java

示例7: getDatabaseColumnTypeDefinition

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
@Override
public String getDatabaseColumnTypeDefinition( DatabaseInterface databaseInterface, String tk, String pk,
  boolean use_autoinc, boolean add_fieldname, boolean add_cr ) {

  String retval = null;
  if ( databaseInterface instanceof PostgreSQLDatabaseMeta ) {
    if ( add_fieldname ) {
      retval = getName() + " ";
    } else {
      retval = "";
    }
    retval += "INET";
    if ( add_cr ) {
      retval += Const.CR;
    }
  }

  return retval;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:20,代码来源:ValueMetaInternetAddress.java

示例8: testGetValueFromSqlTypeNetezza

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
/**
 * PDI-10877 Table input step returns no data when pulling a timestamp column from IBM Netezza
 *
 * @throws Exception
 */
@Test
public void testGetValueFromSqlTypeNetezza() throws Exception {
  ValueMetaBase obj = new ValueMetaBase();
  DatabaseInterface databaseInterface = new NetezzaDatabaseMeta();
  ResultSet resultSet = Mockito.mock( ResultSet.class );
  ResultSetMetaData metaData = Mockito.mock( ResultSetMetaData.class );
  Mockito.when( resultSet.getMetaData() ).thenReturn( metaData );

  Mockito.when( metaData.getColumnType( 1 ) ).thenReturn( Types.DATE );
  Mockito.when( metaData.getColumnType( 2 ) ).thenReturn( Types.TIME );

  obj.type = ValueMetaInterface.TYPE_DATE;
  // call to testing method
  obj.getValueFromResultSet( databaseInterface, resultSet, 0 );
  // for jdbc Date type getDate method called
  Mockito.verify( resultSet, Mockito.times( 1 ) ).getDate( Mockito.anyInt() );

  obj.getValueFromResultSet( databaseInterface, resultSet, 1 );
  // for jdbc Time type getTime method called
  Mockito.verify( resultSet, Mockito.times( 1 ) ).getTime( Mockito.anyInt() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:27,代码来源:ValueMetaBaseTest.java

示例9: testGetValueFromSQLTypeTypeOverride

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
@Test
public void testGetValueFromSQLTypeTypeOverride() throws Exception {
  final int varbinaryColumnIndex = 2;

  ValueMetaBase valueMetaBase = new ValueMetaBase(),
    valueMetaBaseSpy = Mockito.spy( valueMetaBase );
  DatabaseMeta dbMeta = Mockito.mock( DatabaseMeta.class );
  DatabaseInterface databaseInterface = Mockito.mock( DatabaseInterface.class );
  Mockito.doReturn( databaseInterface ).when( dbMeta ).getDatabaseInterface();

  ResultSetMetaData metaData = Mockito.mock( ResultSetMetaData.class );
  valueMetaBaseSpy.getValueFromSQLType( dbMeta, TEST_NAME, metaData, varbinaryColumnIndex, false, false );

  Mockito.verify( databaseInterface, Mockito.times( 1 ) ).customizeValueFromSQLType( Mockito.any( ValueMetaInterface.class ),
    Mockito.any( ResultSetMetaData.class ), Mockito.anyInt() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:17,代码来源:ValueMetaBaseTest.java

示例10: testVerticaTimeType

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
@Test
public void testVerticaTimeType() throws Exception {
  // PDI-12244
  ResultSet resultSet = Mockito.mock( ResultSet.class );
  ResultSetMetaData metaData = Mockito.mock( ResultSetMetaData.class );
  ValueMetaInterface valueMetaInterface = Mockito.mock( ValueMetaInternetAddress.class );

  Mockito.when( resultSet.getMetaData() ).thenReturn( metaData );
  Mockito.when( metaData.getColumnType( 1 ) ).thenReturn( Types.TIME );
  Mockito.when( resultSet.getTime( 1 ) ).thenReturn( new Time( 0 ) );
  Mockito.when( valueMetaInterface.getOriginalColumnType() ).thenReturn( Types.TIME );
  Mockito.when( valueMetaInterface.getType() ).thenReturn( ValueMetaInterface.TYPE_DATE );

  DatabaseInterface databaseInterface = new Vertica5DatabaseMeta();
  Object ret = databaseInterface.getValueFromResultSet( resultSet, valueMetaInterface, 0 );
  assertEquals( new Time( 0 ), ret );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:18,代码来源:ValueMetaBaseTest.java

示例11: testGetValueFromSQLTypeBinaryMysql

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
@Test
public void testGetValueFromSQLTypeBinaryMysql() throws Exception {

  final int binaryColumnIndex = 1;
  ValueMetaBase valueMetaBase = new ValueMetaBase();
  DatabaseMeta dbMeta = Mockito.spy( new DatabaseMeta() );
  DatabaseInterface databaseInterface = new MySQLDatabaseMeta();
  dbMeta.setDatabaseInterface( databaseInterface );

  ResultSet resultSet = Mockito.mock( ResultSet.class );
  ResultSetMetaData metaData = Mockito.mock( ResultSetMetaData.class );

  Mockito.when( resultSet.getMetaData() ).thenReturn( metaData );
  Mockito.when( metaData.getColumnType( binaryColumnIndex ) ).thenReturn( Types.LONGVARBINARY );

  ValueMetaInterface binaryValueMeta =
    valueMetaBase.getValueFromSQLType( dbMeta, TEST_NAME, metaData, binaryColumnIndex, false, false );
  Assert.assertEquals( ValueMetaInterface.TYPE_BINARY, binaryValueMeta.getType() );
  Assert.assertTrue( binaryValueMeta.isBinary() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:21,代码来源:ValueMetaBaseTest.java

示例12: testExceptionStrategyWithPacketTooBigExceptionPropSetY

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
/**
 * Property value has priority
 */
@Test public void testExceptionStrategyWithPacketTooBigExceptionPropSetY() {
  System.setProperty( DatabaseLogExceptionFactory.KETTLE_GLOBAL_PROP_NAME, PROPERTY_VALUE_TRUE );

  DatabaseMeta databaseMeta = mock( DatabaseMeta.class );
  DatabaseInterface databaseInterface = new MySQLDatabaseMeta();
  PacketTooBigException e = new PacketTooBigException();

  when( logTable.getDatabaseMeta() ).thenReturn( databaseMeta );
  when( databaseMeta.getDatabaseInterface() ).thenReturn( databaseInterface );

  LogExceptionBehaviourInterface
    exceptionStrategy =
    DatabaseLogExceptionFactory.getExceptionStrategy( logTable, new KettleDatabaseException( e ) );
  String strategyName = exceptionStrategy.getClass().getName();
  assertEquals( THROWABLE, strategyName );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:20,代码来源:DatabaseLogExceptionFactoryTest.java

示例13: addDatabases

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public void addDatabases( XulMenuList wConnection, Class<? extends DatabaseInterface> databaseType ) {
  List<String> databases = new ArrayList<String>();
  for (int i = 0; i < transMeta.nrDatabases(); i++) {
    DatabaseMeta ci = transMeta.getDatabase(i);
    if (databaseType == null || ci.getDatabaseInterface().getClass().equals(databaseType)) {
      databases.add(ci.getName());
    }
  }
  wConnection.setElements(databases);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:12,代码来源:BaseStepXulDialog.java

示例14: addDatabases

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
public void addDatabases(CCombo wConnection, Class<? extends DatabaseInterface> databaseType) {
  for (int i = 0; i < transMeta.nrDatabases(); i++) {
    DatabaseMeta ci = transMeta.getDatabase(i);
    if (databaseType==null || ci.getDatabaseInterface().getClass().equals(databaseType))
    {
  	  wConnection.add(ci.getName());
    }
  }
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:10,代码来源:BaseStepDialog.java

示例15: getFragment

import org.pentaho.di.core.database.DatabaseInterface; //导入依赖的package包/类
private String getFragment(DatabaseInterface database, String databaseName, String extension, String defaultFragment ){
  String fragment;
  if (database.getXulOverlayFile()!=null) {
  	fragment = packagePath.concat(database.getXulOverlayFile()).concat(extension);
  } else {
  	fragment = packagePath.concat(databaseName).concat(extension);
  }
  InputStream in = getClass().getClassLoader().getResourceAsStream(fragment.toLowerCase());
  if (in == null){
    fragment = packagePath.concat(defaultFragment);
  }
  return fragment;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:14,代码来源:FragmentHandler.java


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