Database Toolbox |
|
Performing Driver Functions
This example demonstrates how to create database driver and drivermanager objects so that you can get and set the object properties. You use these Database Toolbox functions:
Note
There is no equivalent M-file demo to run because the example relies on a specific PC to JDBC connection and database. Your configuration will be different from the one in this example, so you cannot run these examples exactly as written. Instead, use values for your own system. See your database administrator for address information.
|
- Connect to the database.
c = database('orc1','scott','tiger',...
'oracle.jdbc.driver.OracleDriver',...
'jdbc:oracle:thin:@144.212.123.24:1822:');
- Use the
driver
function to construct a driver object for a specified database URL string of the form jdbc:<subprotocol>:<subname>
. For example, type
- MATLAB returns the handle (identifier) for the driver object.
- To get properties of the driver object, type
- MATLAB returns information about the driver's versions.
- To determine if
d
is a valid JDBC driver object, type
- MATLAB returns
which means d
is a valid JDBC driver object. Otherwise, MATLAB would have returned a 0
.
- To set and get properties for all drivers, first create a drivermanager object using the
drivermanager
function. Type
dm
is the drivermanager object.
- Get properties of the drivermanager object. Type
- MATLAB returns
- To set the
LoginTimeout
value to 10
for all drivers loaded during this session, type
- Verify the value by typing
MATLAB returns
The next time you connect to a database, the LoginTimeout
value will be 10
. For example, type
MATLAB returns
For a list of all the driver object functions, see Driver Object and Drivermanager Object.
| Accessing Metadata | | About Objects and Methods for the Database Toolbox | |
© 1994-2005 The MathWorks, Inc.