Generating a Java Bean for your mining code

If you have an existing Java™ application and want to invoke the mining functions provided by Intelligent Miner® from this application, you can generate a specific Java Bean for each mining flow.
The generated Java Bean is a lightweight Java wrapper using JDBC to invoke the SQL statements generated for the mining flow.

To invoke the mining flow, the generated Java class must contain the following execute method:

public void execute(Connection connection) throws SQLException {...}

The caller must provide a JDBC connection and the generated class is then invoking the mining flow's SQL statements over that connection.

If your mining flow contains variables, these variables appear as additional parameters of the execute method.

The Data warehousing in Db2 Design Studio contains the Eclipse Java Development tools (JDT). For details about the JDT, please refer to Java Development User Guide.

Before you begin

  • Create, validate, and execute your mining flow.
  • Create a Java project as described in the Java Development User Guide (File > New > Project > Java Project).

To generate a Java Bean, follow these steps:

  1. Open the mining flow.
  2. Select the mining editor window.
  3. Select Mining Flow > Generate Java Bean (or click the Generate the SQL/DDL script for this mining flow icon The Generate JavaBean icon on the toolbar).
  4. In the Generate Java Bean wizard:
    1. Select a Java project as the source folder.
    2. Specify Package and Class name for the Java Bean.
    3. Press Next.
    4. On the Specify Runtime Connection Information page, you can specify the kind of database connection to use. You can either:
      • Create the database connection outside the generated bean and pass the connection instance as a parameter of the execute method.
      • Refer to a JDBC Data Source and specify the JNDI name for the data source.
    5. Click Finish.

The generated Java Bean is opened in the Java Editor.

Assuming you specified "MBAMiningFlow" as the class name and your mining flow contains three variables (Year, Modelname and Productgroup), the following execute method is generated in your Java Bean:

Figure 1. Sample execute method generated in your Java Bean.Sample execute method generated in your Java Bean

Example

The following simplified code fragment shows how your application can use the mining flow bean:

Figure 2. Sample code fragment that shows how your application can use the mining flow beanSample code fragment that shows how your application can use the mining flow bean


Feedback