User`s guide
2 Getting Started with Database Toolbox
2-118
Oracle JDBC for Mac OS X
This tutorial shows how to set up a data source and connect to your Oracle database.
This tutorial uses the Oracle Database 11g Release 2 (11.2.0.3) JDBC driver for use with
JDK 1.6 to connect to the Oracle 11g Enterprise Edition Release 11.2.0.1.0 database.
In this section...
“Step 1. Verify the driver installation.” on page 2-118
“Step 2. Add the JDBC driver to the MATLAB static Java class path.” on page 2-118
“Step 3. Set up the data source using Database Explorer.” on page 2-119
“Step 4. Connect using Database Explorer or the command line.” on page 2-121
Step 1. Verify the driver installation.
If the JDBC driver for Oracle is not installed on your computer, find the link on the
Driver Installation page to install the driver. Follow the instructions to download and
install this driver on your computer.
Step 2. Add the JDBC driver to the MATLAB static Java class path.
1
Run the prefdir command in the Command Window. The output is a file path to a
folder on your computer.
2
Close MATLAB if it is running.
3
Navigate to the folder and create a file called javaclasspath.txt in the folder.
4
Open javaclasspath.txt. Add the full path to the database driver JAR file
in javaclasspath.txt. The full path includes the path to the folder where
you downloaded the JAR file from the database provider and the JAR file
name. For example, /home/user/DB_Drivers/ojdbc6.jar. Save and close
javaclasspath.txt.
5
Restart MATLAB.
Alternatively, you can use javaaddpath to add your JDBC driver to the dynamic Java
class path. For details about static and dynamic class paths, see “Bringing Java Classes
into MATLAB Workspace”.