User`s guide

database
7-47
Close the database connection conn.
close(conn)
Connect to MySQL Using a JDBC Driver
Connect to a MySQL database using name-value pair arguments to specify the vendor
and connection options.
Connect to the database test_db on the machine remotehost. Use the user name
username and password pwd. For details, see “MySQL JDBC for Windows” on page 2-63.
conn = database('test_db','username','pwd','Vendor','MySQL',...
'Server','remotehost')
conn =
Instance: 'test_db'
UserName: 'username'
Driver: []
URL: []
Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
Message: []
Handle: [1x1 com.mysql.jdbc.JDBC4Connection]
TimeOut: 0
AutoCommit: 'on'
Type: 'Database Object'
conn has an empty Message property, which indicates a successful connection.
Close the database connection conn.
close(conn)
Connect to Microsoft Access Using a File DSN
Connect to a Microsoft Access database with .accdb format using an OBDC driver.
Specify the location of the database on the disk.
dbpath = ['C:\Data\Matlab\MyDatabase.accdb'];
Create the connection URL.
url = [['jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='';DBQ='] dbpath];
Connect to the database MyDatabase.accdb using dpath and url.
conn = database('','','','sun.jdbc.odbc.JdbcOdbcDriver',url);