Database Toolbox Previous page   Next Page

Retrieving BINARY or OTHER Java SQL Data Types

You can retrieve BINARY or OTHER Java SQL data types, however, the data might require additional processing once retrieved. For example, you can retrieve data from a MAT-file or an image file. MATLAB cannot process these data types directly. You need knowledge of the content and might need to massage the data in order to work with it in MATLAB, such as stripping off leading entries added by your driver during data retrieval.

In this example, you import data that includes bitmap images. You use a sample M-file included with the Database Toolbox in the vqb directory:

Perform these steps to retrieve bitmap image data for the example:

  1. Connect to the data source, SampleDB. Type
  2. For the data return format preference, specify either cellarray or structure. For this example, set it to cellarray by typing
  3. Import the data, which includes bitmap image files. For the example, import the EmployeeID and Photo columns of data from the Employees table. Type
  4. View the data you imported by typing
  1. MATLAB returns

    The data in column 2 of the imported data,[21626x1 B[]], indicates that the data type is BINARY.

    Some of the OTHER data type fields might be empty. This happens when Java cannot pass the data through the JDBC/ODBC bridge, for example.

  1. Assign the image element you want to the variable photo. Type
  2. Run the sample program, $matlabroot/toolbox/database/vqb/parsebinary.m, which displays photo as a bitmap image.
  1. The bitmap image displays in a figure window.

    The parsebinary M-file writes the retrieved data to a file, strips ODBC header information, and displays a bitmap image. For more details, type help parsebinary or view the parsebinary M-file in the MATLAB Editor by typing open parsebinary.

This is just one example of retrieving a BINARY or OTHER object. Your application might require different manipulations to process the data in MATLAB.


Previous page  Exporting Multiple New Records from MATLAB Accessing Metadata Next page

© 1994-2005 The MathWorks, Inc.