1*9b5730f6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9b5730f6SAndrew Rist * distributed with this work for additional information 6*9b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9b5730f6SAndrew Rist * "License"); you may not use this file except in compliance 9*9b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at 10*9b5730f6SAndrew Rist * 11*9b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9b5730f6SAndrew Rist * 13*9b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9b5730f6SAndrew Rist * software distributed under the License is distributed on an 15*9b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9b5730f6SAndrew Rist * KIND, either express or implied. See the License for the 17*9b5730f6SAndrew Rist * specific language governing permissions and limitations 18*9b5730f6SAndrew Rist * under the License. 19*9b5730f6SAndrew Rist * 20*9b5730f6SAndrew Rist *************************************************************/ 21*9b5730f6SAndrew Rist 22*9b5730f6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "connectivity/dbmetadata.hxx" 28cdf0e10cSrcweir #include "connectivity/dbexception.hxx" 29cdf0e10cSrcweir #include "connectivity/DriversConfig.hxx" 30cdf0e10cSrcweir #include "resource/common_res.hrc" 31cdf0e10cSrcweir #include "resource/sharedresources.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** === begin UNO includes === **/ 34cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp> 35cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 37cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 38cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp> 39cdf0e10cSrcweir #include <com/sun/star/sdb/BooleanComparisonMode.hpp> 40cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData2.hpp> 41cdf0e10cSrcweir #include <com/sun/star/sdbcx/XUsersSupplier.hpp> 42cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> 43cdf0e10cSrcweir #include <com/sun/star/sdbc/XDriverAccess.hpp> 44cdf0e10cSrcweir /** === end UNO includes === **/ 45cdf0e10cSrcweir 46cdf0e10cSrcweir #include <tools/diagnose_ex.h> 47cdf0e10cSrcweir #include <comphelper/namedvaluecollection.hxx> 48cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 49cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 50cdf0e10cSrcweir 51cdf0e10cSrcweir #include <boost/optional.hpp> 52cdf0e10cSrcweir 53cdf0e10cSrcweir //........................................................................ 54cdf0e10cSrcweir namespace dbtools 55cdf0e10cSrcweir { 56cdf0e10cSrcweir //........................................................................ 57cdf0e10cSrcweir 58cdf0e10cSrcweir /** === begin UNO using === **/ 59cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 60cdf0e10cSrcweir using ::com::sun::star::sdbc::XConnection; 61cdf0e10cSrcweir using ::com::sun::star::sdbc::XConnection; 62cdf0e10cSrcweir using ::com::sun::star::sdbc::XDatabaseMetaData; 63cdf0e10cSrcweir using ::com::sun::star::sdbc::XDatabaseMetaData2; 64cdf0e10cSrcweir using ::com::sun::star::lang::IllegalArgumentException; 65cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 66cdf0e10cSrcweir using ::com::sun::star::uno::Any; 67cdf0e10cSrcweir using ::com::sun::star::container::XChild; 68cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 69cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet; 70cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 71cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue; 72cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySetInfo; 73cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 74cdf0e10cSrcweir using ::com::sun::star::sdbcx::XUsersSupplier; 75cdf0e10cSrcweir using ::com::sun::star::sdbcx::XDataDefinitionSupplier; 76cdf0e10cSrcweir using ::com::sun::star::sdbc::XDriverAccess; 77cdf0e10cSrcweir using ::com::sun::star::uno::UNO_SET_THROW; 78cdf0e10cSrcweir /** === end UNO using === **/ 79cdf0e10cSrcweir namespace BooleanComparisonMode = ::com::sun::star::sdb::BooleanComparisonMode; 80cdf0e10cSrcweir 81cdf0e10cSrcweir //==================================================================== 82cdf0e10cSrcweir //= DatabaseMetaData_Impl 83cdf0e10cSrcweir //==================================================================== 84cdf0e10cSrcweir struct DatabaseMetaData_Impl 85cdf0e10cSrcweir { 86cdf0e10cSrcweir Reference< XConnection > xConnection; 87cdf0e10cSrcweir Reference< XDatabaseMetaData > xConnectionMetaData; 88cdf0e10cSrcweir ::connectivity::DriversConfig aDriverConfig; 89cdf0e10cSrcweir 90cdf0e10cSrcweir ::boost::optional< ::rtl::OUString > sCachedIdentifierQuoteString; 91cdf0e10cSrcweir ::boost::optional< ::rtl::OUString > sCachedCatalogSeparator; 92cdf0e10cSrcweir DatabaseMetaData_Impldbtools::DatabaseMetaData_Impl93cdf0e10cSrcweir DatabaseMetaData_Impl() 94cdf0e10cSrcweir :xConnection() 95cdf0e10cSrcweir ,xConnectionMetaData() 96cdf0e10cSrcweir ,aDriverConfig( ::comphelper::getProcessServiceFactory() ) 97cdf0e10cSrcweir ,sCachedIdentifierQuoteString() 98cdf0e10cSrcweir ,sCachedCatalogSeparator() 99cdf0e10cSrcweir { 100cdf0e10cSrcweir } 101cdf0e10cSrcweir }; 102cdf0e10cSrcweir 103cdf0e10cSrcweir //-------------------------------------------------------------------- 104cdf0e10cSrcweir namespace 105cdf0e10cSrcweir { 106cdf0e10cSrcweir //................................................................ lcl_construct(DatabaseMetaData_Impl & _metaDataImpl,const Reference<XConnection> & _connection)107cdf0e10cSrcweir static void lcl_construct( DatabaseMetaData_Impl& _metaDataImpl, const Reference< XConnection >& _connection ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir _metaDataImpl.xConnection = _connection; 110cdf0e10cSrcweir if ( !_metaDataImpl.xConnection.is() ) 111cdf0e10cSrcweir return; 112cdf0e10cSrcweir 113cdf0e10cSrcweir _metaDataImpl.xConnectionMetaData = _connection->getMetaData(); 114cdf0e10cSrcweir if ( !_metaDataImpl.xConnectionMetaData.is() ) 115cdf0e10cSrcweir throw IllegalArgumentException(); 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir //................................................................ lcl_checkConnected(const DatabaseMetaData_Impl & _metaDataImpl)119cdf0e10cSrcweir static void lcl_checkConnected( const DatabaseMetaData_Impl& _metaDataImpl ) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir if ( !_metaDataImpl.xConnection.is() || !_metaDataImpl.xConnectionMetaData.is() ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir ::connectivity::SharedResources aResources; 124cdf0e10cSrcweir const ::rtl::OUString sError( aResources.getResourceString(STR_NO_CONNECTION_GIVEN)); 125cdf0e10cSrcweir throwSQLException( sError, SQL_CONNECTION_DOES_NOT_EXIST, NULL ); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir //................................................................ lcl_getDriverSetting(const sal_Char * _asciiName,const DatabaseMetaData_Impl & _metaData,Any & _out_setting)130cdf0e10cSrcweir static bool lcl_getDriverSetting( const sal_Char* _asciiName, const DatabaseMetaData_Impl& _metaData, Any& _out_setting ) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir lcl_checkConnected( _metaData ); 133cdf0e10cSrcweir const ::comphelper::NamedValueCollection& rDriverMetaData = _metaData.aDriverConfig.getMetaData( _metaData.xConnectionMetaData->getURL() ); 134cdf0e10cSrcweir if ( !rDriverMetaData.has( _asciiName ) ) 135cdf0e10cSrcweir return false; 136cdf0e10cSrcweir _out_setting = rDriverMetaData.get( _asciiName ); 137cdf0e10cSrcweir return true; 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir //................................................................ lcl_getConnectionSetting(const sal_Char * _asciiName,const DatabaseMetaData_Impl & _metaData,Any & _out_setting)141cdf0e10cSrcweir static bool lcl_getConnectionSetting( const sal_Char* _asciiName, const DatabaseMetaData_Impl& _metaData, Any& _out_setting ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir try 144cdf0e10cSrcweir { 145cdf0e10cSrcweir Reference< XChild > xConnectionAsChild( _metaData.xConnection, UNO_QUERY ); 146cdf0e10cSrcweir if ( xConnectionAsChild.is() ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir Reference< XPropertySet > xDataSource( xConnectionAsChild->getParent(), UNO_QUERY_THROW ); 149cdf0e10cSrcweir Reference< XPropertySet > xDataSourceSettings( 150cdf0e10cSrcweir xDataSource->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings" ) ) ), 151cdf0e10cSrcweir UNO_QUERY_THROW ); 152cdf0e10cSrcweir 153cdf0e10cSrcweir _out_setting = xDataSourceSettings->getPropertyValue( ::rtl::OUString::createFromAscii( _asciiName ) ); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir else 156cdf0e10cSrcweir { 157cdf0e10cSrcweir Reference< XDatabaseMetaData2 > xExtendedMetaData( _metaData.xConnectionMetaData, UNO_QUERY_THROW ); 158cdf0e10cSrcweir ::comphelper::NamedValueCollection aSettings( xExtendedMetaData->getConnectionInfo() ); 159cdf0e10cSrcweir _out_setting = aSettings.get( _asciiName ); 160cdf0e10cSrcweir return _out_setting.hasValue(); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir return true; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir catch( const Exception& ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir return false; 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir //................................................................ lcl_getConnectionStringSetting(const DatabaseMetaData_Impl & _metaData,::boost::optional<::rtl::OUString> & _cachedSetting,::rtl::OUString (SAL_CALL XDatabaseMetaData::* _getter)())172cdf0e10cSrcweir static const ::rtl::OUString& lcl_getConnectionStringSetting( 173cdf0e10cSrcweir const DatabaseMetaData_Impl& _metaData, ::boost::optional< ::rtl::OUString >& _cachedSetting, 174cdf0e10cSrcweir ::rtl::OUString (SAL_CALL XDatabaseMetaData::*_getter)() ) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir if ( !_cachedSetting ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir lcl_checkConnected( _metaData ); 179cdf0e10cSrcweir try 180cdf0e10cSrcweir { 181cdf0e10cSrcweir _cachedSetting.reset( (_metaData.xConnectionMetaData.get()->*_getter)() ); 182cdf0e10cSrcweir } 183cdf0e10cSrcweir catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } 184cdf0e10cSrcweir } 185cdf0e10cSrcweir return *_cachedSetting; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 189cdf0e10cSrcweir //==================================================================== 190cdf0e10cSrcweir //= DatabaseMetaData 191cdf0e10cSrcweir //==================================================================== 192cdf0e10cSrcweir //-------------------------------------------------------------------- DatabaseMetaData()193cdf0e10cSrcweir DatabaseMetaData::DatabaseMetaData() 194cdf0e10cSrcweir :m_pImpl( new DatabaseMetaData_Impl ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir //-------------------------------------------------------------------- DatabaseMetaData(const Reference<XConnection> & _connection)199cdf0e10cSrcweir DatabaseMetaData::DatabaseMetaData( const Reference< XConnection >& _connection ) 200cdf0e10cSrcweir :m_pImpl( new DatabaseMetaData_Impl ) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir lcl_construct( *m_pImpl, _connection ); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir //-------------------------------------------------------------------- DatabaseMetaData(const DatabaseMetaData & _copyFrom)206cdf0e10cSrcweir DatabaseMetaData::DatabaseMetaData( const DatabaseMetaData& _copyFrom ) 207cdf0e10cSrcweir :m_pImpl( new DatabaseMetaData_Impl( *_copyFrom.m_pImpl ) ) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir //-------------------------------------------------------------------- operator =(const DatabaseMetaData & _copyFrom)212cdf0e10cSrcweir DatabaseMetaData& DatabaseMetaData::operator=( const DatabaseMetaData& _copyFrom ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir if ( this == &_copyFrom ) 215cdf0e10cSrcweir return *this; 216cdf0e10cSrcweir 217cdf0e10cSrcweir m_pImpl.reset( new DatabaseMetaData_Impl( *_copyFrom.m_pImpl ) ); 218cdf0e10cSrcweir return *this; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir //-------------------------------------------------------------------- ~DatabaseMetaData()222cdf0e10cSrcweir DatabaseMetaData::~DatabaseMetaData() 223cdf0e10cSrcweir { 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir //-------------------------------------------------------------------- isConnected() const227cdf0e10cSrcweir bool DatabaseMetaData::isConnected() const 228cdf0e10cSrcweir { 229cdf0e10cSrcweir return m_pImpl->xConnection.is(); 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir //-------------------------------------------------------------------- supportsSubqueriesInFrom() const233cdf0e10cSrcweir bool DatabaseMetaData::supportsSubqueriesInFrom() const 234cdf0e10cSrcweir { 235cdf0e10cSrcweir lcl_checkConnected( *m_pImpl ); 236cdf0e10cSrcweir 237cdf0e10cSrcweir bool supportsSubQueries = false; 238cdf0e10cSrcweir try 239cdf0e10cSrcweir { 240cdf0e10cSrcweir sal_Int32 maxTablesInselect = m_pImpl->xConnectionMetaData->getMaxTablesInSelect(); 241cdf0e10cSrcweir supportsSubQueries = ( maxTablesInselect > 1 ) || ( maxTablesInselect == 0 ); 242cdf0e10cSrcweir // TODO: is there a better way to determine this? The above is not really true. More precise, 243cdf0e10cSrcweir // it's a *very* generous heuristics ... 244cdf0e10cSrcweir } 245cdf0e10cSrcweir catch( const Exception& ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 248cdf0e10cSrcweir } 249cdf0e10cSrcweir return supportsSubQueries; 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir //-------------------------------------------------------------------- supportsPrimaryKeys() const253cdf0e10cSrcweir bool DatabaseMetaData::supportsPrimaryKeys() const 254cdf0e10cSrcweir { 255cdf0e10cSrcweir lcl_checkConnected( *m_pImpl ); 256cdf0e10cSrcweir 257cdf0e10cSrcweir bool doesSupportPrimaryKeys = false; 258cdf0e10cSrcweir try 259cdf0e10cSrcweir { 260cdf0e10cSrcweir Any setting; 261cdf0e10cSrcweir if ( !( lcl_getConnectionSetting( "PrimaryKeySupport", *m_pImpl, setting ) ) 262cdf0e10cSrcweir || !( setting >>= doesSupportPrimaryKeys ) 263cdf0e10cSrcweir ) 264cdf0e10cSrcweir doesSupportPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar(); 265cdf0e10cSrcweir } 266cdf0e10cSrcweir catch( const Exception& ) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir return doesSupportPrimaryKeys; 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir //-------------------------------------------------------------------- getIdentifierQuoteString() const274cdf0e10cSrcweir const ::rtl::OUString& DatabaseMetaData::getIdentifierQuoteString() const 275cdf0e10cSrcweir { 276cdf0e10cSrcweir return lcl_getConnectionStringSetting( *m_pImpl, m_pImpl->sCachedIdentifierQuoteString, &XDatabaseMetaData::getIdentifierQuoteString ); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir 279cdf0e10cSrcweir //-------------------------------------------------------------------- getCatalogSeparator() const280cdf0e10cSrcweir const ::rtl::OUString& DatabaseMetaData::getCatalogSeparator() const 281cdf0e10cSrcweir { 282cdf0e10cSrcweir return lcl_getConnectionStringSetting( *m_pImpl, m_pImpl->sCachedCatalogSeparator, &XDatabaseMetaData::getCatalogSeparator ); 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir //-------------------------------------------------------------------- restrictIdentifiersToSQL92() const286cdf0e10cSrcweir bool DatabaseMetaData::restrictIdentifiersToSQL92() const 287cdf0e10cSrcweir { 288cdf0e10cSrcweir lcl_checkConnected( *m_pImpl ); 289cdf0e10cSrcweir 290cdf0e10cSrcweir bool restrict( false ); 291cdf0e10cSrcweir Any setting; 292cdf0e10cSrcweir if ( lcl_getConnectionSetting( "EnableSQL92Check", *m_pImpl, setting ) ) 293cdf0e10cSrcweir OSL_VERIFY( setting >>= restrict ); 294cdf0e10cSrcweir return restrict; 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir //-------------------------------------------------------------------- generateASBeforeCorrelationName() const298cdf0e10cSrcweir bool DatabaseMetaData::generateASBeforeCorrelationName() const 299cdf0e10cSrcweir { 300cdf0e10cSrcweir bool doGenerate( true ); 301cdf0e10cSrcweir Any setting; 302cdf0e10cSrcweir if ( lcl_getConnectionSetting( "GenerateASBeforeCorrelationName", *m_pImpl, setting ) ) 303cdf0e10cSrcweir OSL_VERIFY( setting >>= doGenerate ); 304cdf0e10cSrcweir return doGenerate; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir //-------------------------------------------------------------------- shouldEscapeDateTime() const307cdf0e10cSrcweir bool DatabaseMetaData::shouldEscapeDateTime() const 308cdf0e10cSrcweir { 309cdf0e10cSrcweir bool doGenerate( true ); 310cdf0e10cSrcweir Any setting; 311cdf0e10cSrcweir if ( lcl_getConnectionSetting( "EscapeDateTime", *m_pImpl, setting ) ) 312cdf0e10cSrcweir OSL_VERIFY( setting >>= doGenerate ); 313cdf0e10cSrcweir return doGenerate; 314cdf0e10cSrcweir } 315cdf0e10cSrcweir //-------------------------------------------------------------------- isAutoIncrementPrimaryKey() const316cdf0e10cSrcweir bool DatabaseMetaData::isAutoIncrementPrimaryKey() const 317cdf0e10cSrcweir { 318cdf0e10cSrcweir bool is( true ); 319cdf0e10cSrcweir Any setting; 320cdf0e10cSrcweir if ( lcl_getDriverSetting( "AutoIncrementIsPrimaryKey", *m_pImpl, setting ) ) 321cdf0e10cSrcweir OSL_VERIFY( setting >>= is ); 322cdf0e10cSrcweir return is; 323cdf0e10cSrcweir } 324cdf0e10cSrcweir //-------------------------------------------------------------------- getBooleanComparisonMode() const325cdf0e10cSrcweir sal_Int32 DatabaseMetaData::getBooleanComparisonMode() const 326cdf0e10cSrcweir { 327cdf0e10cSrcweir sal_Int32 mode( BooleanComparisonMode::EQUAL_INTEGER ); 328cdf0e10cSrcweir Any setting; 329cdf0e10cSrcweir if ( lcl_getConnectionSetting( "BooleanComparisonMode", *m_pImpl, setting ) ) 330cdf0e10cSrcweir OSL_VERIFY( setting >>= mode ); 331cdf0e10cSrcweir return mode; 332cdf0e10cSrcweir } 333cdf0e10cSrcweir //-------------------------------------------------------------------- supportsRelations() const334cdf0e10cSrcweir bool DatabaseMetaData::supportsRelations() const 335cdf0e10cSrcweir { 336cdf0e10cSrcweir lcl_checkConnected( *m_pImpl ); 337cdf0e10cSrcweir bool bSupport = false; 338cdf0e10cSrcweir try 339cdf0e10cSrcweir { 340cdf0e10cSrcweir bSupport = m_pImpl->xConnectionMetaData->supportsIntegrityEnhancementFacility(); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir catch( const Exception& ) 343cdf0e10cSrcweir { 344cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 345cdf0e10cSrcweir } 346cdf0e10cSrcweir try 347cdf0e10cSrcweir { 348cdf0e10cSrcweir if ( !bSupport ) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir const ::rtl::OUString url = m_pImpl->xConnectionMetaData->getURL(); 351cdf0e10cSrcweir char pMySQL[] = "sdbc:mysql"; 352cdf0e10cSrcweir bSupport = url.matchAsciiL(pMySQL,(sizeof(pMySQL)/sizeof(pMySQL[0]))-1); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir } 355cdf0e10cSrcweir catch( const Exception& ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 358cdf0e10cSrcweir } 359cdf0e10cSrcweir return bSupport; 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir //-------------------------------------------------------------------- supportsColumnAliasInOrderBy() const363cdf0e10cSrcweir bool DatabaseMetaData::supportsColumnAliasInOrderBy() const 364cdf0e10cSrcweir { 365cdf0e10cSrcweir bool doGenerate( true ); 366cdf0e10cSrcweir Any setting; 367cdf0e10cSrcweir if ( lcl_getConnectionSetting( "ColumnAliasInOrderBy", *m_pImpl, setting ) ) 368cdf0e10cSrcweir OSL_VERIFY( setting >>= doGenerate ); 369cdf0e10cSrcweir return doGenerate; 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir //-------------------------------------------------------------------- supportsUserAdministration(const::comphelper::ComponentContext & _rContext) const373cdf0e10cSrcweir bool DatabaseMetaData::supportsUserAdministration( const ::comphelper::ComponentContext& _rContext ) const 374cdf0e10cSrcweir { 375cdf0e10cSrcweir lcl_checkConnected( *m_pImpl ); 376cdf0e10cSrcweir 377cdf0e10cSrcweir bool isSupported( false ); 378cdf0e10cSrcweir try 379cdf0e10cSrcweir { 380cdf0e10cSrcweir // find the XUsersSupplier interface 381cdf0e10cSrcweir // - either directly at the connection 382cdf0e10cSrcweir Reference< XUsersSupplier > xUsersSupp( m_pImpl->xConnection, UNO_QUERY ); 383cdf0e10cSrcweir if ( !xUsersSupp.is() ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir // - or at the driver manager 386cdf0e10cSrcweir Reference< XDriverAccess > xDriverManager( 387cdf0e10cSrcweir _rContext.createComponent( "com.sun.star.sdbc.DriverManager" ), UNO_QUERY_THROW ); 388cdf0e10cSrcweir Reference< XDataDefinitionSupplier > xDriver( xDriverManager->getDriverByURL( m_pImpl->xConnectionMetaData->getURL() ), UNO_QUERY ); 389cdf0e10cSrcweir if ( xDriver.is() ) 390cdf0e10cSrcweir xUsersSupp.set( xDriver->getDataDefinitionByConnection( m_pImpl->xConnection ), UNO_QUERY ); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir isSupported = ( xUsersSupp.is() && xUsersSupp->getUsers().is() ); 394cdf0e10cSrcweir } 395cdf0e10cSrcweir catch( const Exception& ) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir return isSupported; 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402cdf0e10cSrcweir //-------------------------------------------------------------------- displayEmptyTableFolders() const403cdf0e10cSrcweir bool DatabaseMetaData::displayEmptyTableFolders() const 404cdf0e10cSrcweir { 405cdf0e10cSrcweir bool doDisplay( true ); 406cdf0e10cSrcweir #ifdef IMPLEMENTED_LATER 407cdf0e10cSrcweir Any setting; 408cdf0e10cSrcweir if ( lcl_getConnectionSetting( "DisplayEmptyTableFolders", *m_pImpl, setting ) ) 409cdf0e10cSrcweir OSL_VERIFY( setting >>= doDisplay ); 410cdf0e10cSrcweir #else 411cdf0e10cSrcweir try 412cdf0e10cSrcweir { 413cdf0e10cSrcweir Reference< XDatabaseMetaData > xMeta( m_pImpl->xConnectionMetaData, UNO_SET_THROW ); 414cdf0e10cSrcweir ::rtl::OUString sConnectionURL( xMeta->getURL() ); 415cdf0e10cSrcweir doDisplay = sConnectionURL.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "sdbc:mysql:mysqlc" ) ) == 0; 416cdf0e10cSrcweir } 417cdf0e10cSrcweir catch( const Exception& ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 420cdf0e10cSrcweir } 421cdf0e10cSrcweir #endif 422cdf0e10cSrcweir return doDisplay; 423cdf0e10cSrcweir } 424cdf0e10cSrcweir //-------------------------------------------------------------------- supportsThreads() const425cdf0e10cSrcweir bool DatabaseMetaData::supportsThreads() const 426cdf0e10cSrcweir { 427cdf0e10cSrcweir bool bSupported( true ); 428cdf0e10cSrcweir try 429cdf0e10cSrcweir { 430cdf0e10cSrcweir Reference< XDatabaseMetaData > xMeta( m_pImpl->xConnectionMetaData, UNO_SET_THROW ); 431cdf0e10cSrcweir ::rtl::OUString sConnectionURL( xMeta->getURL() ); 432cdf0e10cSrcweir bSupported = sConnectionURL.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "sdbc:mysql:mysqlc" ) ) != 0; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir catch( const Exception& ) 435cdf0e10cSrcweir { 436cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir return bSupported; 439cdf0e10cSrcweir } 440cdf0e10cSrcweir 441cdf0e10cSrcweir //........................................................................ 442cdf0e10cSrcweir } // namespace dbtools 443cdf0e10cSrcweir //........................................................................ 444cdf0e10cSrcweir 445