Database Toolbox Previous page   Next Page
get

Get object properties

Syntax

Description

v = get(object) returns a structure of the properties of object and the corresponding property values, assigning the structure to v.

v = get(object, 'property') retrieves the value of property for object, assigning the value to v.

v.property returns the value of property, after you have created v using get.

Use set(object) to see a list of writable properties for object.

Allowable objects are

If you are calling these objects from your own Java-based applications, see http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html for more information about the object properties.

Database Connection Object

Allowable property names and returned values for a database connection object are listed in the following table.

Property
Value
'AutoCommit'
Status of the AutoCommit flag, either on or off, as specified by set
'Catalog'
Names of catalogs in the data source, for example, 'Nwind'
'Driver'
Driver used for the JDBC connection, as specified by database
'Handle'
Identifying JDBC connection object
'Instance'
Name of the data source for an ODBC connection or the database for a JDBC connection, as specified by database
'Message'
Error message returned by database
'ReadOnly'
1 if the database is read only; 0 if the database is writable
'TimeOut'
Value for LoginTimeout
'TransactionIsolation'
Value of current transaction isolation mode
'Type'
Object type, specifically Database Object
'URL'
For a JDBC connection only, the JDBC URL object, jdbc:subprotocol:subname, as specified by database
'UserName'
Username required to connect to the database, as specified by database; note that you cannot use get to retrieve password
'Warnings'
Warnings returned by database

Cursor Object

Allowable property names and returned values for a cursor object are listed in the following table.

Property
Value
'Attributes'
Cursor attributes
'Data'
Data in the cursor object data element (the query results)
'DatabaseObject'
Information about the database object
'RowLimit'
Maximum number of rows to be returned by fetch, as specified by set
'SQLQuery'
SQL statement for the cursor, as specified by exec
'Message'
Error message returned from exec or fetch
'Type'
Object type, specifically Database Cursor Object
'ResultSet'
Resultset object identifier
'Cursor'
Cursor object identifier
'Statement'
Statement object identifier
'Fetch'
0 for cursor created using exec; fetchTheData for cursor created using fetch

Driver Object

Allowable property names and examples of values for a driver object are listed in the following table.

Property
Example of Value
'MajorVersion'
1
'MinorVersion'
1001

Database Metadata Object

There are dozens of properties for a database metadata object. Some of the allowable property names and examples of their values are listed in the following table.

Property
Example of Value
'Catalogs'
{4x1 cell}
'DatabaseProductName'
'ACCESS'
'DatabaseProductVersion'
'03.50.0000'
'DriverName'
'JDBC-ODBC Bridge (odbcjt32.dll)'
'MaxColumnNameLength'
64
'MaxColumnsInOrderBy'
10
'URL'
'jdbc:odbc:dbtoolboxdemo'
'NullsAreSortedLow'
1

Drivermanager Object

Allowable property names and examples of values for a drivermanager object are listed in the following table.

Property
Example of Value
'Drivers'
{'oracle.jdbc.driver.OracleDriver@1d8e09ef' [1x37 char]}
'LoginTimeout'
0
'LogStream'
[]

Resultset Object

Some of the allowable property names for a resultset object and examples of their values are listed in the following table.

Property
Example of Value
'CursorName'
{'SQL_CUR92535700x' 'SQL_CUR92535700x'}
'MetaData'
{1x2 cell}
'Warnings'
{[] []}

Resultset Metadata Object

Allowable property names for a resultset metadata object and examples of values are listed in the following table.

Property
Example of Value
'CatalogName'
{'' ''}
'ColumnCount'
2
'ColumnName'
{'Calc_Date' 'Avg_Cost'}
'ColumnTypeName'
{'TEXT' 'LONG'}
'TableName'
{'' ''}
'isNullable'
{[1] [1]}
'isReadOnly'
{[0] [0]}

The empty strings for CatalogName and TableName indicate that the database does not return these values.

For command line help on get, use the overloaded methods.

Examples

Example 1--Get Connection Property, Data Source Name

Connect to the database, SampleDB. Then get the name of the data source for the connection and assign it to v.

MATLAB returns

Example 2--Get Connection Property, AutoCommit Flag Status

Determine the status of the AutoCommit flag for the database connection conn.

Example 3--Display Data in Cursor

Display the data in the cursor object, curs, by typing

or by typing

MATLAB returns

In this example, curs contains one column with four records.

Example 4--Get Database Metadata Object Properties

View the properties of the database metadata object for connection conn. Type

MATLAB returns a list of properties, some of which are shown here.

To view the names of the catalogs in the database, type

MATLAB returns the catalog names

See Also

columns, database, dmd, driver, drivermanager, exec, fetch, resultset, rows, rsmd, set


Previous page  fetch importedkeys Next page

© 1994-2005 The MathWorks, Inc.