diff options
author | Oliver Bolte <obo@openoffice.org> | 2009-02-16 07:31:09 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2009-02-16 07:31:09 +0000 |
commit | 9ca79e4a309c35023dfad6cb755be6c93f301a8a (patch) | |
tree | 3aee5da0eb7f33bdb351fb438bd3df45865e84a9 /connectivity/source/drivers | |
parent | 3a5f60b72b0a123227ac6be0a5d3ad69b62c9ee1 (diff) |
CWS-TOOLING: integrate CWS mysql1
2009-01-29 13:25:23 +0100 fs r267126 : #i98559#
2009-01-29 10:29:23 +0100 fs r267100 : #i98559#
2009-01-29 09:56:20 +0100 fs r267098 : do not display empty schematas in the table list in the query designer
2009-01-29 09:40:28 +0100 fs r267097 : corrected acceptsURL
2009-01-28 11:17:42 +0100 fs r267042 : display empty catalogs/schemas, if indicated by the connection settings
2009-01-28 11:14:30 +0100 fs r267040 : +displayEmptyTableFolders
2009-01-28 11:03:28 +0100 fs r267036 : mysql:mysqlc, not mysql:mysql, for the native driver
2009-01-28 10:23:53 +0100 fs r267031 : select the first catalog/schema, if the guess for the current one did not match
2009-01-28 10:22:23 +0100 fs r267030 : select the first catalog/schema, if the guess for the current one did not match
2009-01-27 15:03:29 +0100 fs r266996 : #i10000#
2009-01-27 14:56:13 +0100 fs r266992 : #i20563# better (more dedicated) UI for the MySQL native driver's properties
2009-01-27 08:20:24 +0100 oj r266953 : enable sdbcx mysql driver for mysqlc
2009-01-27 08:20:09 +0100 oj r266952 : enable sdbcx mysql driver for mysqlc
Diffstat (limited to 'connectivity/source/drivers')
-rw-r--r-- | connectivity/source/drivers/mysql/YDriver.cxx | 91 |
1 files changed, 69 insertions, 22 deletions
diff --git a/connectivity/source/drivers/mysql/YDriver.cxx b/connectivity/source/drivers/mysql/YDriver.cxx index 9dd1815ca787..dcee418b88e5 100644 --- a/connectivity/source/drivers/mysql/YDriver.cxx +++ b/connectivity/source/drivers/mysql/YDriver.cxx @@ -68,7 +68,7 @@ namespace connectivity ODriverDelegator::ODriverDelegator(const Reference< XMultiServiceFactory >& _rxFactory) : ODriverDelegator_BASE(m_aMutex) ,m_xFactory(_rxFactory) - ,m_bUseOdbc(sal_True) + ,m_eDriverType(D_ODBC) { } @@ -78,6 +78,7 @@ namespace connectivity try { ::comphelper::disposeComponent(m_xODBCDriver); + ::comphelper::disposeComponent(m_xNativeDriver); TJDBCDrivers::iterator aIter = m_aJdbcDrivers.begin(); TJDBCDrivers::iterator aEnd = m_aJdbcDrivers.end(); for ( ;aIter != aEnd;++aIter ) @@ -112,11 +113,28 @@ namespace connectivity return _sUrl.copy(0,16).equalsAscii("sdbc:mysql:odbc:"); } //-------------------------------------------------------------------- + sal_Bool isNativeUrl(const ::rtl::OUString& _sUrl) + { + return (!_sUrl.compareTo(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:")), sizeof("sdbc:mysql:mysqlc:")-1)); + } + //-------------------------------------------------------------------- + T_DRIVERTYPE lcl_getDriverType(const ::rtl::OUString& _sUrl) + { + T_DRIVERTYPE eRet = D_JDBC; + if ( isOdbcUrl(_sUrl ) ) + eRet = D_ODBC; + else if ( isNativeUrl(_sUrl ) ) + eRet = D_NATIVE; + return eRet; + } + //-------------------------------------------------------------------- ::rtl::OUString transformUrl(const ::rtl::OUString& _sUrl) { ::rtl::OUString sNewUrl = _sUrl.copy(11); if ( isOdbcUrl( _sUrl ) ) sNewUrl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:")) + sNewUrl; + else if ( isNativeUrl( _sUrl ) ) + sNewUrl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:")) + sNewUrl; else { sNewUrl = sNewUrl.copy(5); @@ -139,7 +157,7 @@ namespace connectivity return xDriver; } //-------------------------------------------------------------------- - Sequence< PropertyValue > lcl_convertProperties(sal_Bool _bOdbc,const Sequence< PropertyValue >& info) + Sequence< PropertyValue > lcl_convertProperties(T_DRIVERTYPE _eType,const Sequence< PropertyValue >& info,const ::rtl::OUString& _sUrl) { ::std::vector<PropertyValue> aProps; const PropertyValue* pSupported = info.getConstArray(); @@ -151,7 +169,7 @@ namespace connectivity aProps.push_back( *pSupported ); } - if ( _bOdbc ) + if ( _eType == D_ODBC ) { aProps.push_back( PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Silent")) @@ -164,7 +182,7 @@ namespace connectivity ,makeAny(sal_True) ,PropertyState_DIRECT_VALUE) ); } - else + else if ( _eType == D_JDBC ) { aProps.push_back( PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass")) @@ -172,6 +190,14 @@ namespace connectivity ,makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.mysql.jdbc.Driver"))) ,PropertyState_DIRECT_VALUE) ); } + else + { + aProps.push_back( PropertyValue( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NewURL")) + ,0 + ,makeAny(_sUrl) + ,PropertyState_DIRECT_VALUE) ); + } aProps.push_back( PropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsAutoRetrievingEnabled")) ,0 @@ -195,20 +221,25 @@ namespace connectivity Reference< XDriver > ODriverDelegator::loadDriver( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) { Reference< XDriver > xDriver; - ::rtl::OUString sCuttedUrl = transformUrl(url); - sal_Bool bIsODBC = isOdbcUrl( url ); - if ( bIsODBC ) + const ::rtl::OUString sCuttedUrl = transformUrl(url); + const T_DRIVERTYPE eType = lcl_getDriverType( url ); + if ( eType == D_ODBC ) { if ( !m_xODBCDriver.is() ) m_xODBCDriver = lcl_loadDriver(m_xFactory,sCuttedUrl); xDriver = m_xODBCDriver; + } // if ( bIsODBC ) + else if ( eType == D_NATIVE ) + { + if ( !m_xNativeDriver.is() ) + m_xNativeDriver = lcl_loadDriver(m_xFactory,sCuttedUrl); + xDriver = m_xNativeDriver; } else { ::comphelper::NamedValueCollection aSettings( info ); ::rtl::OUString sDriverClass(RTL_CONSTASCII_USTRINGPARAM("com.mysql.jdbc.Driver")); sDriverClass = aSettings.getOrDefault( "JavaDriverClass", sDriverClass ); - ::rtl::OUString sCharSet = aSettings.getOrDefault( "CharSet", ::rtl::OUString() ); TJDBCDrivers::iterator aFind = m_aJdbcDrivers.find(sDriverClass); if ( aFind == m_aJdbcDrivers.end() ) @@ -230,9 +261,9 @@ namespace connectivity if ( xDriver.is() ) { ::rtl::OUString sCuttedUrl = transformUrl(url); - const sal_Bool bIsODBC = isOdbcUrl( url ); - Sequence< PropertyValue > aConvertedProperties = lcl_convertProperties(bIsODBC,info); - if ( !bIsODBC ) + const T_DRIVERTYPE eType = lcl_getDriverType( url ); + Sequence< PropertyValue > aConvertedProperties = lcl_convertProperties(eType,info,url); + if ( eType == D_JDBC ) { ::comphelper::NamedValueCollection aSettings( info ); ::rtl::OUString sIanaName = aSettings.getOrDefault( "CharSet", ::rtl::OUString() ); @@ -284,14 +315,13 @@ namespace connectivity //-------------------------------------------------------------------- sal_Bool SAL_CALL ODriverDelegator::acceptsURL( const ::rtl::OUString& url ) throw (SQLException, RuntimeException) { - sal_Bool bOK = sal_False; - if ( url.getLength() >= 16 ) - { - ::rtl::OUString sPrefix = url.copy(0,16); - bOK = sPrefix.equalsAscii("sdbc:mysql:odbc:"); - if ( !bOK ) - bOK = sPrefix.equalsAscii("sdbc:mysql:jdbc:"); - } + Sequence< PropertyValue > info; + + sal_Bool bOK = url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "sdbc:mysql:odbc:" ) ) + || url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "sdbc:mysql:jdbc:" ) ) + || ( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "sdbc:mysql:mysqlc:" ) ) + && loadDriver( url, info ).is() + ); return bOK; } @@ -302,8 +332,6 @@ namespace connectivity if ( !acceptsURL(url) ) return Sequence< DriverPropertyInfo >(); - sal_Bool bIsODBC = isOdbcUrl( url ); - Sequence< ::rtl::OUString > aBoolean(2); aBoolean[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0")); aBoolean[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1")); @@ -323,7 +351,8 @@ namespace connectivity ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0")) ,aBoolean) ); - if ( !bIsODBC ) + const T_DRIVERTYPE eType = lcl_getDriverType( url ); + if ( eType == D_JDBC ) { aDriverInfo.push_back(DriverPropertyInfo( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass")) @@ -377,6 +406,24 @@ namespace connectivity } } } + } // if ( xTunnel.is() ) + if ( !xTab.is() ) + { + TWeakPairVector::iterator aEnd = m_aConnections.end(); + for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i) + { + Reference< XConnection > xTemp(i->first.get(),UNO_QUERY); + if ( xTemp == connection ) + { + xTab = Reference< XTablesSupplier >(i->second.first.get().get(),UNO_QUERY); + if ( !xTab.is() ) + { + xTab = new OMySQLCatalog(connection); + i->second.first = WeakReferenceHelper(xTab); + } + break; + } + } } return xTab; } |