summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-07-30 09:01:01 +0200
committerFridrich Strba <fridrich@documentfoundation.org>2013-07-30 10:01:05 +0000
commit9957058b1cf9460df23d03d90e2276c33ea33cdc (patch)
tree0fae918a8115d3c39e9d1b45ba69ba444c00e9cc
parentbac2e995debd58957bdca24ba29f4817a752e020 (diff)
rhbz#989246: Honor user's JavaDriverClass override in mysql driver
(cherry picked from commit 63897351fc4fd31305bef43b649be74e2b6006c4) Conflicts: connectivity/source/drivers/mysql/YDriver.cxx Change-Id: Ic7dbddb5b17af0bd23864fd19ab2bd815969d008 Reviewed-on: https://gerrit.libreoffice.org/5197 Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-rw-r--r--connectivity/source/drivers/mysql/YDriver.cxx36
1 files changed, 25 insertions, 11 deletions
diff --git a/connectivity/source/drivers/mysql/YDriver.cxx b/connectivity/source/drivers/mysql/YDriver.cxx
index 941f47c1ec58..6ff63cb1dbc3 100644
--- a/connectivity/source/drivers/mysql/YDriver.cxx
+++ b/connectivity/source/drivers/mysql/YDriver.cxx
@@ -47,6 +47,15 @@ namespace connectivity
}
}
+ namespace
+ {
+ OUString getJavaDriverClass(
+ css::uno::Sequence<css::beans::PropertyValue> const & info)
+ {
+ return comphelper::NamedValueCollection(info).getOrDefault(
+ "JavaDriverClass", OUString("com.mysql.jdbc.Driver"));
+ }
+ }
//====================================================================
//= ODriverDelegator
@@ -157,9 +166,14 @@ namespace connectivity
const PropertyValue* pEnd = pSupported + info.getLength();
aProps.reserve(info.getLength() + 5);
+ bool jdc = false;
for (;pSupported != pEnd; ++pSupported)
{
aProps.push_back( *pSupported );
+ if (pSupported->Name == "JavaDriverClass")
+ {
+ jdc = true;
+ }
}
if ( _eType == D_ODBC )
@@ -177,11 +191,14 @@ namespace connectivity
}
else if ( _eType == D_JDBC )
{
- aProps.push_back( PropertyValue(
- ::rtl::OUString("JavaDriverClass")
- ,0
- ,makeAny(::rtl::OUString("com.mysql.jdbc.Driver"))
- ,PropertyState_DIRECT_VALUE) );
+ if (!jdc)
+ {
+ aProps.push_back( PropertyValue(
+ ::rtl::OUString("JavaDriverClass")
+ ,0
+ ,makeAny(::rtl::OUString("com.mysql.jdbc.Driver"))
+ ,PropertyState_DIRECT_VALUE) );
+ }
}
else
{
@@ -230,10 +247,7 @@ namespace connectivity
}
else
{
- ::comphelper::NamedValueCollection aSettings( info );
- ::rtl::OUString sDriverClass("com.mysql.jdbc.Driver");
- sDriverClass = aSettings.getOrDefault( "JavaDriverClass", sDriverClass );
-
+ OUString sDriverClass(getJavaDriverClass(info));
TJDBCDrivers::iterator aFind = m_aJdbcDrivers.find(sDriverClass);
if ( aFind == m_aJdbcDrivers.end() )
aFind = m_aJdbcDrivers.insert(TJDBCDrivers::value_type(sDriverClass,lcl_loadDriver(m_xFactory,sCuttedUrl))).first;
@@ -319,7 +333,7 @@ namespace connectivity
}
//--------------------------------------------------------------------
- Sequence< DriverPropertyInfo > SAL_CALL ODriverDelegator::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw (SQLException, RuntimeException)
+ Sequence< DriverPropertyInfo > SAL_CALL ODriverDelegator::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException)
{
::std::vector< DriverPropertyInfo > aDriverInfo;
if ( !acceptsURL(url) )
@@ -351,7 +365,7 @@ namespace connectivity
::rtl::OUString("JavaDriverClass")
,::rtl::OUString("The JDBC driver class name.")
,sal_True
- ,::rtl::OUString("com.mysql.jdbc.Driver")
+ ,getJavaDriverClass(info)
,Sequence< ::rtl::OUString >())
);
}