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. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Connection Options

You can connect to a database in various ways using Database Toolbox™. If you have access to a database, create a data source. Then, you can connect to the database either by using the Database Explorer app or the command line. If you do not have an installed database and want to store relational data quickly, you can use the MATLAB® interface to SQLite. For details, see Working with MATLAB Interface to SQLite.

Creating or Connecting to Data Source

If you already have a database driver installed, you can create a data source. For an ODBC driver, use the Microsoft® ODBC Data Source Administrator. For a JDBC driver, add the path of the driver to the Java® class path in MATLAB. For examples, see Configuring Driver and Data Source. Otherwise, see Driver Installation for information about installing your driver. If your data sources are defined, then you are ready to connect to your database. For details, see Connecting to Database. After establishing a connection, you can explore the database and view data using the Database Explorer app or the command line. For details, see Data Import Using Database Explorer App or Command Line.

Defining Operating System Authentication

Operating system authentication enables you to connect to a database using your operating system user account. The operating system performs user validation, and the database does not require a different user name and password. Operating system authentication facilitates the maintenance of database access credentials. For example, Windows® provides operating system authentication that can be configured to work with a Microsoft SQL Server® database. For details about Microsoft SQL Server Windows authentication, see Set up the operating system authentication.

Connection Options

Use this table to choose your best connection option.

Connection Option

Why Use This Option?

Database Explorer app

Use the Database Explorer app to:

  • Visually inspect the structure, or schema, of a database.

  • Assess the general size of a database by viewing the database structure.

  • Select the data in a table and import it into a MATLAB variable.

  • Generate a MATLAB script.

  • Generate an SQL query.

Command line

Use the command line to:

  • Import data from a database into MATLAB.

  • Export data from MATLAB into a database.

  • Work with large amounts of data.

  • Run SQL queries stored in text files.

  • Run stored procedures and functions.

There are multiple options to connect to your database using the command line. Use this table to choose your best connection option.

Command-Line Connection Option

Why Use This Option?

ODBC connection

Connect to your database with maximum performance. For details, see Connecting to Database Using Native ODBC Interface.

JDBC connection

Achieve maximum platform independence. Use functionality not supported by native ODBC.

SQLite connection

Import data without installing a database or a driver. For details, see Working with MATLAB Interface to SQLite.

You can create multiple connections at a time to the same database or a different database. For creating multiple connections using the Database Explorer app, see Create SQL Queries Using Database Explorer App. Or, you can use the database function to create multiple connections at the command line.

See Also

Related Topics

Was this topic helpful?