This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Other ODBC-Compliant or JDBC-Compliant Databases

This tutorial provides steps for configuring data sources and connecting to other ODBC-compliant or JDBC-compliant databases that are not listed in Configuring Driver and Data Source. After creating a data source, you can connect to your database using the Database Explorer app or the command line.

ODBC-Compliant Databases

These steps show how to configure a driver and connect to an ODBC-compliant database with MATLAB®. Database Toolbox™ can connect to any ODBC-compliant database that is relational and uses ANSI® SQL. For example, if your database is Microsoft® Excel® or IBM DB2®, follow these basic steps:

  1. If your driver is not preinstalled on your computer, find a compatible driver and install it on your computer. You can view preinstalled drivers using the Microsoft ODBC Data Source Administrator dialog box. For details about this dialog box, see Driver Installation.

  2. Create a data source by using the installed driver and the Microsoft ODBC Data Source Administrator dialog box.

  3. Use the Database Explorer app to test your connection and connect to your database. For an example, see MySQL ODBC for Windows.

    Or, you can connect to your database using the database function at the command line.

  4. For detailed assistance, contact your database administrator or refer to your database documentation.

JDBC-Compliant Databases

These steps show how to configure a driver and connect to a JDBC-compliant database with MATLAB. Database Toolbox can connect to any JDBC-compliant database that is relational and uses ANSI SQL. For example, if your database is Apache™ Derby or Microsoft Windows® Azure®, follow these basic steps:

Note

The details of these steps can vary depending on your database and database version. For detailed assistance, contact your database administrator or refer to your database documentation.

  1. If your driver is not preinstalled on your computer, find a compatible driver and install it on your computer.

  2. Create a data source by using the JDBC Data Source Configuration dialog box. For details about this dialog box, see the configureJDBCDataSource function.

  3. In the Name box, enter a name for your data source. You use this name to establish a connection to your database.

  4. From the Vendor list, select OTHER.

  5. In the Driver Location box, specify the full path of the driver file.

  6. To connect to a JDBC-compliant database, you must know your database driver Java® class object. For example, the Java class object for an SQLite database driver is org.sqlite.JDBC. In the Driver box, specify this driver value.

    Note

    For JDBC-compliant databases, specify the driver and URL in the JDBC Data Source Configuration dialog box. The driver and the URL string can vary depending on the type and version of the JDBC driver and the database you are working with. For details about the driver and URL, see the JDBC driver documentation for your database.

  7. To connect to a JDBC-compliant database, you must create a URL string. The URL string is in the form jdbc:subprotocol:subname. The jdbc part of this string stays constant for any JDBC driver. subprotocol is the database type. The last part of the URL string is subname. The subname contains the location of the database and additional connection information, such as the port number. For example, if you are using SQLite, the string is jdbc:sqlite:dbpath, where dbpath is the full path to your SQLite database on your computer. In the URL box, specify this URL string.

  8. Click Test to test your connection. If the connection is successful, then click Save to save the JDBC data source.

  9. Connect to your database with the saved JDBC data source by using the Database Explorer app or the database function at the command line. For an example, see SQLite JDBC for Windows.

See Also

Apps

Functions

Related Examples

More About