Class AsyncDatabaseAction

java.lang.Object
org.pentaho.di.core.util.AsyncDatabaseAction

public class AsyncDatabaseAction extends Object
Static methods for asynchronous execution of actions on a Database, with a set timeout for the async thread. The .executeAction() method takes a Consumer, which defines what action to take on the Database. The .executeSql / .getTables / .getSchemas / etc. methods are convenience methods which leverage .executeAction() to retrieve specific info. These methods can be used wherever Database info needs to be retrieved without blocking the calling thread, for example with setting UI elements: AsyncDatabaseAction.getTables( dbMeta, schemaName, tables -> display.asyncExec(() -> combo.setItems(tables)) Note that the action of setting the items still needs to happen on the SWT display thread, hence the need for display.asyncExec(). So with the above two lines, AsyncDatabaseAction thread retrieves the table array from the database, When retrieved, `combo.setItems(tables)` is put on the display thread's queue.
  • Method Details

    • executeAction

      public static void executeAction(org.pentaho.di.core.database.DatabaseMeta databaseMeta, Consumer<org.pentaho.di.core.database.Database> dbAction)
    • executeSql

      public static void executeSql(org.pentaho.di.core.database.DatabaseMeta databaseMeta, String sql, Consumer<List<Object[]>> rowConsumer)
    • getTables

      public static void getTables(org.pentaho.di.core.database.DatabaseMeta databaseMeta, String schema, Consumer<String[]> tablesConsumer)
    • getSchemas

      public static void getSchemas(org.pentaho.di.core.database.DatabaseMeta databaseMeta, Consumer<String[]> schemasConsumer)
    • getFields

      public static void getFields(org.pentaho.di.core.database.DatabaseMeta databaseMeta, String tablename, Consumer<org.pentaho.di.core.row.RowMetaInterface> fieldsConsumer)