Java Code Examples for org.pentaho.di.core.database.Database#getTablenames()

The following examples show how to use org.pentaho.di.core.database.Database#getTablenames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CopyTableWizardPage2.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean getInputData() {
  // Get some data...
  CopyTableWizardPage1 page1 = (CopyTableWizardPage1) getPreviousPage();

  Database sourceDb = new Database( CopyTableWizard.loggingObject, page1.getSourceDatabase() );
  try {
    sourceDb.connect();
    input = sourceDb.getTablenames();
  } catch ( KettleDatabaseException dbe ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "CopyTableWizardPage2.ErrorGettingTables.DialogTitle" ),
      BaseMessages.getString( PKG, "CopyTableWizardPage2.ErrorGettingTables.DialogMessage" ), dbe );
    input = null;
    return false;
  } finally {
    sourceDb.disconnect();
  }
  return true;
}
 
Example 2
Source File: RipDatabaseWizardPage2.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean getInputData() {
  // Get some data...
  RipDatabaseWizardPage1 page1 = (RipDatabaseWizardPage1) getPreviousPage();

  Database sourceDb = new Database( RipDatabaseWizard.loggingObject, page1.getSourceDatabase() );
  try {
    sourceDb.connect();
    input = sourceDb.getTablenames( false ); // Don't include the schema since it can cause invalid syntax
  } catch ( KettleDatabaseException dbe ) {
    new ErrorDialog( shell, "Error getting tables", "Error obtaining table list from database!", dbe );
    input = null;
    return false;
  } finally {
    sourceDb.disconnect();
  }
  return true;
}
 
Example 3
Source File: JobEntryTruncateTablesDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void getTableName() {
  DatabaseMeta databaseMeta = jobMeta.findDatabase( wConnection.getText() );
  if ( databaseMeta != null ) {
    Database database = new Database( loggingObject, databaseMeta );
    try {
      database.connect();
      String[] Tablenames = database.getTablenames();
      Arrays.sort( Tablenames );
      EnterSelectionDialog dialog = new EnterSelectionDialog( shell, Tablenames,
        BaseMessages.getString( PKG, "JobTruncateTables.SelectTables.Title" ),
        BaseMessages.getString( PKG, "JobTruncateTables.SelectTables.Message" ) );
      dialog.setMulti( true );
      dialog.setAvoidQuickSearch();
      if ( dialog.open() != null ) {
        int[] idx = dialog.getSelectionIndeces();
        for ( int i = 0; i < idx.length; i++ ) {
          TableItem tableItem = new TableItem( wFields.table, SWT.NONE );
          tableItem.setText( 1, Tablenames[idx[i]] );
        }
      }
    } catch ( KettleDatabaseException e ) {
      new ErrorDialog( shell,
        BaseMessages.getString( PKG, "System.Dialog.Error.Title" ),
        BaseMessages.getString( PKG, "JobEntryTruncateTables.ConnectionError.DialogMessage" ), e );
    } finally {
      if ( database != null ) {
        database.disconnect();
      }
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth( true );

  }

}