此内容没有您所选择的语言版本。

7.3. Model a JDBC Source


This section shows how to model a JDBC Source, using the Guide View action set. For this example, we will connect to a MySQL database, but you can use the same process to connect to any supported database.
  1. Open Guides View

    To open the Teiid Designer's Guides view, on the main menu, click Window >Show View > Other... and then click Teiid Designer > Guides view in the dialog.
    The Guides view is shown below, with the Model JDBC Source Action Set selected:

    Figure 7.1. Guides View

  2. Define Teiid Model Project

    Note

    First, you can see Define Model Project dialog where you can choose existing project by clicking Existing... button or create new project by clicking New... button. Next steps describe the creation of new Teiid Model Project.
    1. The Define Teiid Model Project action launches the New Model Project wizard. In the Action Set list, double-click the action (or select the action, then click Execute selected action). The wizard is launched as shown below:
      Enter a project name, for example, MyProject in the Name field. Then click Next.

      Figure 7.2. New Project Wizard

    2. The next page of the wizard is Project References which allows you to select other projects which this project will reference. Click Next.
    3. The next page of the wizard is shown below:

      Figure 7.3. New Project Folders

    4. Under Create Folders, clear schemas and web_services. We will not need them for this example. Now, click Finish to exit the wizard. The project has now been created.
      Your Model Explorer view will look like this:

      Figure 7.4. Model Explorer

  3. Create JDBC connection

    The Create JDBC connection action will create the Connection profile for your database. The connection profile defines the properties and driver to be used when connecting to the database. In the Action Set list, double-click the action (or select it, then click Execute selected action). The wizard is launched as shown below:

    Figure 7.5. Connection Profile Name and Type

    Select the type of database that you are connecting to (for example, MySQL), and enter a name for the connection profile, for example, TestMySQL. Click Next.

    Figure 7.6. Connection Profile properties

    Now, select the driver and enter the login properties for your database. Click Finish to complete the profile creation.
  4. Create source model for JDBC data source

    1. The Create source model for JDBC data source action will now utilize the Connection profile that you have created, to import the metadata from the database to create your Teiid Source Model. In the Action Set list, double-click the action (or select it, then click Execute selected action). The wizard is launched as shown below:

      Figure 7.7. Select Connection Profile

    2. On this page, select the TestMySQL Connection profile that you created in the previous step. Click Next.

      Figure 7.8. Select Database Metadata

    3. On this page, select the database metadata that you want to import. When finished, click Next.

      Figure 7.9. Select Database Objects

    4. On this page, select the specific objects from the database that you want to import. When finished, click Next.

      Figure 7.10. Import Options

    5. Finally, choose the name for the model to be created (defaults to profileName.xmi). The Into Folder field defines the target location for your new model. Select the MyProject/sources folder. Now, click Finish. The source model has now been created. Your Model Explorer view will look like this:

      Figure 7.11. Model Explorer

  5. Preview Data

    All execution capabilities in Teiid Designer (Preview Data, VDB execution) require you to connect to a running JBoss Data Virtualization Server. See Server Management chapter for instructions on establishing a JBoss Data Virtualization Server connection. Once you are connected to a JBoss Data Virtualization Server, you can proceed with the following steps.
    1. The Preview Data action allows you to preview a sample of data rows from your source. In the Action Set list, double-click the action (or select it, then click Execute selected action).
    2. In the first dialog, click ... button and then select the source table you want to preview, as shown below:

      Figure 7.12. Select Preview Table

    3. After selecting the table, click OK button in both dialogs. After that, the Custom Preview Data dialog is shown when you can see SQL query and VDB XML Content. Click OK for running query.

      Note

      When the server is not running during creating source model, you can get Data Sources Missing dialog. Just click to Yes for creating a new data source.

      Figure 7.13. Custom Preview Data

    4. Now, the preview results will be displayed:

      Figure 7.14. Preview Results

  6. Define VDB

    1. The Define VDB action allows you to create a VDB (Virtual Database) artifact for deployment to a JBoss Data Virtualization Server. In the Action Set list, double-click the action (or select it, then click Execute selected action). If you choose to create a new VDB, the following dialog is displayed:

      Figure 7.15. New VDB

    2. In the dialog, select the target In Folder location where the VDB will be placed. Enter a Name for the VDB, for example myVDB. Finally, select the models that will be included in the VDB. When finished, click Finish. The VDB will be created in your Teiid Model Project as shown in the following figure.

      Figure 7.16. Model Explorer

  7. Edit VDB

    The Edit VDB action opens VDB editor for editing VDB.
  8. Execute VDB

    The Execute VDB action allows you to execute your VDB and run sample queries against it. In the Action Set list, double-click the action (or select it, then click Execute selected action). In the dialog, select the VDB you want to execute, then click OK. The VDB will be deployed and executed, and the perspective will switch to the Database Development perspective. You can now run queries against the VDB, as show in the following example:

    Figure 7.17. Execute VDB Example

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat