parent
0068b30b88
commit
01fb3649a8
@ -0,0 +1,103 @@
|
||||
From 0c1d2fcdcfbfe83317e8660dd6165f3b438e80ad Mon Sep 17 00:00:00 2001
|
||||
From: Stephan Bergmann <sbergman@redhat.com>
|
||||
Date: Tue, 30 Jul 2013 09:01:01 +0200
|
||||
Subject: [PATCH] rhbz#989246: Honor user's JavaDriverClass override in mysql
|
||||
driver
|
||||
|
||||
Change-Id: Ic7dbddb5b17af0bd23864fd19ab2bd815969d008
|
||||
(cherry picked from commit 63897351fc4fd31305bef43b649be74e2b6006c4)
|
||||
Reviewed-on: https://gerrit.libreoffice.org/5193
|
||||
Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org>
|
||||
Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
|
||||
---
|
||||
connectivity/source/drivers/mysql/YDriver.cxx | 36 +++++++++++++++++++--------
|
||||
1 file changed, 25 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/connectivity/source/drivers/mysql/YDriver.cxx b/connectivity/source/drivers/mysql/YDriver.cxx
|
||||
index bd826e0..b55f464 100644
|
||||
--- a/connectivity/source/drivers/mysql/YDriver.cxx
|
||||
+++ b/connectivity/source/drivers/mysql/YDriver.cxx
|
||||
@@ -49,6 +49,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
|
||||
@@ -156,9 +165,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 )
|
||||
@@ -176,11 +190,14 @@ namespace connectivity
|
||||
}
|
||||
else if ( _eType == D_JDBC )
|
||||
{
|
||||
- aProps.push_back( PropertyValue(
|
||||
- OUString("JavaDriverClass")
|
||||
- ,0
|
||||
- ,makeAny(OUString("com.mysql.jdbc.Driver"))
|
||||
- ,PropertyState_DIRECT_VALUE) );
|
||||
+ if (!jdc)
|
||||
+ {
|
||||
+ aProps.push_back( PropertyValue(
|
||||
+ OUString("JavaDriverClass")
|
||||
+ ,0
|
||||
+ ,makeAny(OUString("com.mysql.jdbc.Driver"))
|
||||
+ ,PropertyState_DIRECT_VALUE) );
|
||||
+ }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -229,10 +246,7 @@ namespace connectivity
|
||||
}
|
||||
else
|
||||
{
|
||||
- ::comphelper::NamedValueCollection aSettings( info );
|
||||
- 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_xContext,sCuttedUrl))).first;
|
||||
@@ -318,7 +332,7 @@ namespace connectivity
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- Sequence< DriverPropertyInfo > SAL_CALL ODriverDelegator::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw (SQLException, RuntimeException)
|
||||
+ Sequence< DriverPropertyInfo > SAL_CALL ODriverDelegator::getPropertyInfo( const OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException)
|
||||
{
|
||||
::std::vector< DriverPropertyInfo > aDriverInfo;
|
||||
if ( !acceptsURL(url) )
|
||||
@@ -350,7 +364,7 @@ namespace connectivity
|
||||
OUString("JavaDriverClass")
|
||||
,OUString("The JDBC driver class name.")
|
||||
,sal_True
|
||||
- ,OUString("com.mysql.jdbc.Driver")
|
||||
+ ,getJavaDriverClass(info)
|
||||
,Sequence< OUString >())
|
||||
);
|
||||
}
|
||||
--
|
||||
1.8.1.4
|
||||
|
Loading…
Reference in new issue