Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

get

Retrieve object properties

driver and drivermanager have been removed.

resultset and rsmd will be removed in a future release.

Syntax

Description

example

s = get(object) returns a structure s that contains the object and its corresponding properties.

example

v = get(object,property) returns the value v of property for the object.

Examples

collapse all

Retrieve the properties of a database metadata object created using a database connection object.

Establish connection conn to a MySQL® database with user name username and password pwd.

conn = database('MySQL','username','pwd');

Alternatively, you can use the native ODBC interface for an ODBC connection. For details, see database.

Construct a database metadata object dbmeta using the database connection object conn.

dbmeta = dmd(conn);

Retrieve the properties of dbmeta and assign them to MATLAB® variable v.

v = get(dbmeta)
v = 

                 AllProceduresAreCallable: 1
                   AllTablesAreSelectable: 1
    DataDefinitionCausesTransactionCommit: 1
      DataDefinitionIgnoredInTransactions: 0
               DoesMaxRowSizeIncludeBlobs: 0
                                 Catalogs: {8x1 cell}
                         CatalogSeparator: '.'
                              CatalogTerm: 'DATABASE'
                      DatabaseProductName: 'ACCESS'
                   DatabaseProductVersion: '04.00.0000'
              DefaultTransactionIsolation: 2
                       DriverMajorVersion: 2
                       DriverMinorVersion: 1
                               DriverName: 'JDBC-ODBC Bridge (ACEODBC.DLL)'
                            DriverVersion: '2.0001 (Microsoft Access database engine)'
                      ExtraNameCharacters: '~@#$%^&*_-+=\}{"';:?/><,.![]|'
                    IdentifierQuoteString: '`'
                         IsCatalogAtStart: 1
                   MaxBinaryLiteralLength: 255
                     MaxCatalogNameLength: 260
                     MaxCharLiteralLength: 255
                      MaxColumnNameLength: 64
                      MaxColumnsInGroupBy: 10
                        MaxColumnsInIndex: 10
                      MaxColumnsInOrderBy: 10
                       MaxColumnsInSelect: 255
                        MaxColumnsInTable: 255
                           MaxConnections: 64
                      MaxCursorNameLength: 64
                           MaxIndexLength: 255
                   MaxProcedureNameLength: 64
                               MaxRowSize: 4052
                      MaxSchemaNameLength: 0
                       MaxStatementLength: 65000
                            MaxStatements: 0
                       MaxTableNameLength: 64
                        MaxTablesInSelect: 16
                        MaxUserNameLength: 0
                         NumericFunctions: [1x73 char]
                            ProcedureTerm: 'QUERY'
                                  Schemas: {}
                               SchemaTerm: ''
                       SearchStringEscape: '\'
                              SQLKeywords: [1x255 char]
                          StringFunctions: [1x91 char]
               StoresLowerCaseIdentifiers: 0
         StoresLowerCaseQuotedIdentifiers: 0
               StoresMixedCaseIdentifiers: 0
         StoresMixedCaseQuotedIdentifiers: 1
               StoresUpperCaseIdentifiers: 0
         StoresUpperCaseQuotedIdentifiers: 0
                          SystemFunctions: ''
                               TableTypes: {18x1 cell}
                        TimeDateFunctions: [1x111 char]
                                 TypeInfo: {16x1 cell}
                                      URL: 'jdbc:odbc:tutorial2'
                                 UserName: 'admin'
                    NullPlusNonNullIsNull: 0
                      NullsAreSortedAtEnd: 0
                    NullsAreSortedAtStart: 0
                       NullsAreSortedHigh: 0
                        NullsAreSortedLow: 1
                    UsesLocalFilePerTable: 0
                           UsesLocalFiles: 1

Display the contents of the Catalogs property of v.

v.Catalogs
ans = 
    'D:\matlab\toolbox\database\dbdemos\db1'
    'D:\matlab\toolbox\database\dbdemos\origtutorial'
    'D:\matlab\toolbox\database\dbdemos\tutorial'
    'D:\matlab\toolbox\database\dbdemos\tutorial1'

Close the connection.

close(conn)

Retrieve the 'AutoCommit' property of the database connection object.

Establish connection conn to a MySQL database with user name username and password pwd.

conn = database('MySQL','username','pwd');

Alternatively, you can use the native ODBC interface for an ODBC connection. For details, see database.

Check the status of the 'AutoCommit' property for the database connection conn.

v = get(conn,'AutoCommit')
v = 
	on

Close the connection.

close(conn)

Related Examples

Input Arguments

collapse all

Database Toolbox object, specified as the following allowable objects:

  • Database connection object, which is created using database

  • Cursor object, which is created using exec or fetch

  • Database metadata object, which is created using dmd

  • Resultset object, which is created using resultset

  • Resultset metadata object, which is created using rsmd

Property of the Database Toolbox object, specified as a character vector.

For database connection objects, see this table for the available property names and returned values.

Database Connection Object PropertyDescription
'AutoCommit'

'on' or 'off', as specified by set. When 'AutoCommit' is set to 'on', the database automatically commits changes to the data. When 'AutoCommit' is set to 'off', the database requires an execution of the SQL COMMIT statement for committing changes to the data.

'Catalog'

Name of the catalog in the data source. Extract a single catalog name from 'Catalog' for functions such as columns, which accept only a single catalog.

'Driver'

Driver used for a JDBC connection, as specified by database.

'Handle'

JDBC connection object.

'Instance'

Name of the data source for an ODBC connection or the name of a 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'

Number of seconds that the driver waits while trying to establish a database connection before throwing an error.

'Type'

Object type, specifically 'Database Object'.

'URL'

For JDBC connections only, the JDBC URL object jdbc:subprotocol:subname, as specified by database.

'UserName'

User name required to connect to a given database, as specified by database.

'Warnings'

Warnings returned by database.

You cannot use the get function to retrieve the Password property.

For cursor objects, see this table for the available property names and returned values.

Cursor Object PropertyDescription
'Attributes'

Cursor attributes. This field is always empty. Use the attr function to retrieve cursor attributes.

'Data'

Data in the cursor object data element (the query results).

'DatabaseObject'

Information about a given database object.

'RowLimit'

Maximum number of rows returned by fetch, as specified by set.

'SQLQuery'

SQL statement for a cursor, as specified by exec.

'Message'

Error message returned from exec or fetch.

'Type'

Object type, specifically 'Database Cursor Object'.

'ResultSet'

Handle to Java® resultset object.

'Cursor'

Handle to Java cursor object.

'Statement'

Handle to Java statement object.

'Fetch'

0 for a cursor created using exec; fetchTheData for a cursor created using fetch.

'Scrollable'

Logical value to identify the cursor object as scrollable or basic. This property is set to 1 for a scrollable cursor and 0 otherwise. This property is hidden and read-only.

'Position'

Current position of the cursor in the data set. This property is only available for a scrollable cursor. This property behaves differently for native ODBC, JDBC, and different database drivers. This property is read-only.

For database metadata objects, see this table for the available property names and returned values.

Database Metadata Object PropertyDescriptionExample of Value
'Catalogs'

List of database catalogs

{'toystore' 'dbo'}

'DatabaseProductName'

Database vendor name

'ACCESS'

'DatabaseProductVersion'

Database version number

'03.50.0000'

'DriverName'

Name of the JDBC or ODBC driver

'JDBC-ODBC Bridge (odbcjt32.dll)'

'MaxColumnNameLength'

Maximum length of the database column name

64

'MaxColumnsInOrderBy'

Maximum number of database columns for sorting the data

10

'URL'

JDBC database URL for establishing a connection

'jdbc:odbc:dbtoolboxdemo'

For resultset objects, see this table for the available property names and returned values.

Resultset Object PropertyDescriptionExample of Value
'CursorName'

Internal Java cursor object name

{'SQL_CUR92535700x' 'SQL_CUR92535700x'}

'MetaData'

Information about the cursor object

{1x2 cell}

'Warnings'

Query execution warnings

{[] []}

For resultset metadata objects, see this table for the available property names and returned values.

Resultset Metadata Object PropertyDescriptionExample of Value
'CatalogName'

Database catalog name

{'toystore' 'dbo'}

'ColumnCount'

Number of columns in the resultset

2

'ColumnName'

Column names in the resultset

{'Calc_Date' 'Avg_Cost'}

'ColumnTypeName'

Database column data types

{'TEXT' 'LONG'}

'isNullable'

Whether database column can contain NULL values

{[1] [1]}

'isReadOnly'

Whether database column is read only

{[0] [0]}

'TableName'

The table name where the column resides

{'' ''}

When CatalogName and TableName contain the value {'' ''}, databases do not return metadata for catalog and table names.

Data Types: char

Output Arguments

collapse all

Object properties, returned as a structure that contains the object and its corresponding properties.

Object property value, returned as a character vector, numeric value, cell array, or object.

More About

collapse all

Tips

  • For database connection objects and cursor objects, you can use the native ODBC interface with this function. For details about establishing a connection using the native ODBC interface, see database.

Introduced before R2006a

Was this topic helpful?