Database Toolbox Previous page   Next Page

Accessing Metadata

In this example, you access information about the database, which is called the metadata. You use these Database Toolbox functions:

  1. Connect to the dbtoolboxdemo data source. Type
  1. MATLAB returns information about the database object.

  1. To view additional information about the database, you first construct a database metadata object using the dmd function. Type
  1. MATLAB returns the handle (identifier) for the metadata object.

  1. To view a list of properties associated with the database, use the get function for the metadata object you just created, dbmeta.
  1. MATLAB returns a long list of properties associated with the database.

  1. Some information is too long to fit in the field's display area and instead the size of the information in the field is reported. For example, the Catalogs element is shown as a {4x1 cell}. To view the actual Catalog information, type
  1. MATLAB returns

    For more information about the database metadata properties returned by get, see the methods of the DatabaseMetaData object at
    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html.

  1. To see the properties that this database supports, use the supports function. Type
  1. MATLAB returns

    A 1 means the database supports that property, while a 0 means the database does not support that property. For the above example, the GroupBy property has a value of 1, meaning the database supports the SQL group by feature.

    For more information about the properties supported by the database, see the methods of the DatabaseMetaData object at
    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html.

  1. There are other Database Toolbox functions you can use to access additional database metadata. For example, to retrieve the names of the tables in a catalog in the database, use the tables function. Type
  1. where dbmeta is the name of the database metadata object you created for the database using dmd in step 2, and tutorial is the name of the catalog for which you want to retrieve table names. (You retrieved catalog names in step 4.)

    MATLAB returns the names and types for each table.

    Two of these tables were used in a previous example: salesVolume and yearlySales.

    For a list of all of the database metadata functions, see Database Metadata Object. Some databases do not support all of these functions.

  1. Close the database connection. Type

Resultset Metadata Object

Similar to the dmd function are the resultset and rsmd functions. Use resultset to create a resultset object for a cursor object that you created using exec or fetch. You can then view properties of the resultset object using get, create a resultset metadata object using rsmd and get its properties, or make calls to the resultset object using your own Java-based applications. For more information, see the reference pages for resultset and rsmd, or see the lists of related functions, Resultset Object and Resultset Metadata Object.


Previous page  Retrieving BINARY or OTHER Java SQL Data Types Performing Driver Functions Next page

© 1994-2005 The MathWorks, Inc.