XDatabaseMetaData Interface

From Apache OpenOffice Wiki
Jump to: navigation, search

The com.sun.star.sdbc.XDatabaseMetaData interface is the largest interface existing in the SDBC API. This interface knows everything about the used database. It provides information, such as the available tables with their columns, keys and indexes, and information about identifiers that should be used. This chapter explains some of the methods that are frequently used and how they are used to achieve a robust Driver.

Important Methods of com.sun.star.sdbc.XDatabaseMetaData
isReadOnly() Returns the state of the database. When true, the database is not editable later in OpenOffice.org API.
usesLocalFiles() Returns true when the catalog name of the database should not appear in the DatasourceBrowser of OpenOffice.org API, otherwise false is returned.
supportsMixedCaseQuotedIdentifiers() When this method returns true,the quoted identifiers are case sensitive. For example, in a driver that supports mixed case quoted identifiers, SELECT * FROM "MyTable" retrieves data from a table with the case-sensitive name MyTable.
getTables() Returns a ResultSet object that returns a single row for each table that fits the search criteria, such as the catalog name, schema pattern, table name pattern and sequence of table types. The correct column count and names of the columns are found at com.sun.star.sdbc.XDatabaseMetaData:getTables(). If this method does not return any rows, this driver does not work with Apache OpenOffice API.

Any other getXXX() method can be implemented step by step. For the first step they return an empty ResultSet object that contains no rows. It is not allowed to return NULL here.

The skeleton driver defines empty ResultSets for these get methods.

  Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( 
      const Any& catalog, const ::rtl::OUString& schemaPattern, 
      const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) 
      throw(SQLException, RuntimeException)
      // this returns an empty resultset where the column-names are already set
      // in special the metadata of the resultset already returns the right columns
      ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet();
      Reference< XResultSet > xResultSet = pResultSet;
      return xResultSet;
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages