Using Driver Functions

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

    Note   There is no equivalent MATLAB® example available because this example relies on a specific system-to-JDBC connection and database. Your configuration is different from the one in this example, so you cannot run these examples exactly as written. Instead, substitute appropriate values for your own system. See your database administrator for details.

  1. Connect to the database.

    c = database('orc1','scott','tiger',... 
  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:@')
    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.

    ans =

    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.


    Verify the LoginTimeout value.

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