Hi André ,

A. Klitzing wrote:
Hello,

I have a problem with "ODatabaseMetaDataResultSet". I can't find any
documentation about it and I don't know how it works.
Do you mean the class in connectivity/source/inc/FDatabaseMetaDataResultSet.hxx? In that class all table structures are defined which you need to create the correct resultset for every method of the databasemetadata which returns a resultset. E.g. When you have a look in source/drivers/odbc/ODatabaseMetaData.cxx ::getTableTypes there the resultset will be created and the correct metadata for the resultset will be set. ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet();
   Reference< XResultSet > xRef = pResult;
pResult->setTableTypes(); // set metadata for the resultset -> XResultSetMetaData

Afterwords the data is collected

   ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
   for(sal_Int32 i=0;i < nSize;++i)
   {
       ::connectivity::ODatabaseMetaDataResultSet::ORow aRow;
aRow.push_back(::connectivity::ODatabaseMetaDataResultSet::getEmptyValue()); // the first value must be this one aRow.push_back(new ::connectivity::ORowSetValueDecorator(sTableTypes[i]));

       aRows.push_back(aRow);
   }
// set the data at the resultset
   pResult->setRows(aRows);
// last but not least return it
    return xRef;
The table structure (resultset structure) can be found in the documentation of the com.sun.star.sdbc.XDatabaseMetaData
http://api.openoffice.org/docs/common/ref/com/sun/star/sdbc/XDatabaseMetaData.html#getTableTypes
I wanted to add table information to it in
ODatabaseMetaData::getTableType() to get the tables but it don't work.
My connection to the database works... but I can't see table-names in
oobase.
The getTableTypes method only return the types of tables supported by the database. Returning "TABLE" and "VIEW" should be enough. See above. When you want to see tables you have to implement getTables(...). You may do something like that

   // most classes already have a mutex like this one
   ::osl::MutexGuard aGuard( m_aMutex );

   ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet();
   Reference< XResultSet > xRef = pResult;
// see http://api.openoffice.org/docs/common/ref/com/sun/star/sdbc/XDatabaseMetaData.html#getTables
   pResult->setTablesMap();
   ODatabaseMetaDataResultSet::ORows aRows;
   for(allMyTables)
   {
ODatabaseMetaDataResultSet::ORow aRow(3); // the first 3 values aren't needed so far (0,catalog, schema)
           aRow.reserve(6);
aRow.push_back(new ORowSetValueDecorator(aName)); // TABLE NAME aRow.push_back(new ORowSetValueDecorator(aTable)); // TABLE TYPE aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); // REMARKS
           aRows.push_back(aRow);
   }

By the way...
Where can I get / include a MutexGuard that I can use in functions like
getTableType?
#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif

When you need a mutex in member initialization you must derive your class in first place from ::cppu::BaseMutex so that the mutex is already available when you want to use it.
#include <cppuhelper/basemutex.hxx>
Thanks,
André Klitzing

-- OJ

--
Ocke Janssen                      Tel: +49 40 23646 661, x66661
Dipl. Inf(FH)                     Fax: +49 40 23646 550
Sun Microsystems Inc.
Nagelsweg 55                     mailto:[EMAIL PROTECTED]
D-20097 Hamburg                   http://www.sun.com/staroffice

Example isn't another way to teach, it is the only way to teach. Albert Einstein

Reply via email to