Products & Services Solutions Academia Support User Community Company

Learn more about Database Toolbox   

Using Driver Functions

This example uses the following Database Toolbox functions to create driver and drivermanager objects, and to get and set their properties:

  1. Connect to the database.

    c = database('orc1','scott','tiger',... 
    'oracle.jdbc.driver.OracleDriver',... 
    'jdbc:oracle:thin:@144.212.123.24:1822:');
    
  2. Use the driver function to construct a driver object and return its handle, for a specified database URL string of the form jdbc:subprotocol:subname.

    d = driver('jdbc:oracle:thin:@144.212.123.24:1822:')
    DriverHandle: [1x1 oracle.jdbc.driver.OracleDriver]
    
  3. Use the get function to get information, such as version data, for the driver object.

    v = get(d)
    v = 
    	MajorVersion: 1
    	MinorVersion: 0
    
  4. Use isdriver to verify that d is a valid JDBC driver object.

    isdriver(d)
    ans =
    	1
    

    This result shows that d is a valid JDBC driver object. If it is a not valid JDBC driver object, the returned result is 0.

  5. Use the drivermanager function to create a drivermanager object dm.

    dm = drivermanager
    
  6. Get properties of the drivermanager object.

    v = get(dm)
    v = 
           Drivers: {'sun.jdbc.odbc.JdbcOdbcDriver@761630' ...
    			[1x38 char]}
      LoginTimeout: 0
         LogStream: []
    
  7. Set the LoginTimeout value to 10 for all drivers loaded during this session.

    set(dm,'LoginTimeout',10)
    

    Verify the LoginTimeout value.

    v = get(dm)
    v = 
          Drivers: {'sun.jdbc.odbc.JdbcOdbcDriver@761630'}
     LoginTimeout: 10
        LogStream: []
    

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS