connectivity/source/drivers/firebird/Connection.cxx | 39 +++++++++++++++++--- connectivity/source/drivers/firebird/Connection.hxx | 8 ++++ connectivity/source/drivers/firebird/Driver.cxx | 6 +-- connectivity/source/drivers/firebird/Driver.hxx | 4 +- connectivity/source/inc/java/sql/Connection.hxx | 2 - 5 files changed, 49 insertions(+), 10 deletions(-)
New commits: commit e58c7886fe3dc830a14433078b8a1bea52a85f11 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Thu Nov 7 19:15:54 2013 +0100 typo in comment Change-Id: Iea5084bd1c5765197e5dcf379637a780e52f42bd diff --git a/connectivity/source/inc/java/sql/Connection.hxx b/connectivity/source/inc/java/sql/Connection.hxx index 148a8d7..fc276c4 100644 --- a/connectivity/source/inc/java/sql/Connection.hxx +++ b/connectivity/source/inc/java/sql/Connection.hxx @@ -62,7 +62,7 @@ namespace connectivity @param _sSQL The SQL statement to transform. @return - The new statement witgh unnamed parameters. + The new statement with unnamed parameters. */ OUString transFormPreparedStatement(const OUString& _sSQL); void loadDriverFromProperties( commit aaee12a8a84df2568b2262ee991a61ab926ae6c6 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Thu Nov 7 19:15:38 2013 +0100 fdo#65108 inter-module includes <> Change-Id: Ie7e08f25741772f657a71369483917d989a05537 diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 3d552d9..b2dfcc0 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -44,11 +44,11 @@ #include <com/sun/star/ucb/SimpleFileAccess.hpp> #include <com/sun/star/ucb/XSimpleFileAccess2.hpp> -#include "connectivity/dbexception.hxx" +#include <connectivity/dbexception.hxx> #include <connectivity/sqlparse.hxx> -#include "resource/common_res.hrc" -#include "resource/hsqldb_res.hrc" -#include "resource/sharedresources.hxx" +#include <resource/common_res.hrc> +#include <resource/hsqldb_res.hrc> +#include <resource/sharedresources.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/storagehelper.hxx> commit c2ad6017e66909e9797bc728ac28a9575c84343e Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Thu Nov 7 19:12:23 2013 +0100 firebird-sdbc: replace named parameter by unnamed Change-Id: Iad6023d9d16b10001bb8493dea483e655fc8519c diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 67e7a9d..3d552d9 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -45,6 +45,7 @@ #include <com/sun/star/ucb/XSimpleFileAccess2.hpp> #include "connectivity/dbexception.hxx" +#include <connectivity/sqlparse.hxx> #include "resource/common_res.hrc" #include "resource/hsqldb_res.hrc" #include "resource/sharedresources.hxx" @@ -372,6 +373,30 @@ Reference< XStatement > SAL_CALL Connection::createStatement( ) return xReturn; } +OUString Connection::transformPreparedStatement(const OUString& _sSQL) +{ + OUString sSqlStatement (_sSQL); + try + { + OSQLParser aParser( m_pDriver->getContext() ); + OUString sErrorMessage; + OUString sNewSql; + OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,_sSQL); + if(pNode) + { // special handling for parameters + OSQLParseNode::substituteParameterNames(pNode); + pNode->parseNodeToStr( sNewSql, this ); + delete pNode; + sSqlStatement = sNewSql; + } + } + catch(const Exception&) + { + SAL_WARN("connectivity.firebird", "failed to remove named parameters from '" << _sSQL << "'"); + } + return sSqlStatement; +} + Reference< XPreparedStatement > SAL_CALL Connection::prepareStatement( const OUString& _sSql) throw(SQLException, RuntimeException) @@ -384,9 +409,11 @@ Reference< XPreparedStatement > SAL_CALL Connection::prepareStatement( if(m_aTypeInfo.empty()) buildTypeInfo(); + OUString sSqlStatement (transformPreparedStatement( _sSql )); + Reference< XPreparedStatement > xReturn = new OPreparedStatement(this, m_aTypeInfo, - _sSql); + sSqlStatement); m_aStatements.push_back(WeakReferenceHelper(xReturn)); return xReturn; @@ -401,6 +428,8 @@ Reference< XPreparedStatement > SAL_CALL Connection::prepareCall( MutexGuard aGuard( m_aMutex ); checkDisposed(Connection_BASE::rBHelper.bDisposed); + OUString sSqlStatement (transformPreparedStatement( _sSql )); + // not implemented yet :-) a task to do return NULL; } diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx index a2f7dfe..6c8dba4 100644 --- a/connectivity/source/drivers/firebird/Connection.hxx +++ b/connectivity/source/drivers/firebird/Connection.hxx @@ -156,6 +156,14 @@ namespace connectivity throw(::com::sun::star::sdbc::SQLException); void disposeStatements(); + /** transform named parameters into unnamed parameters + @param _sSQL + The SQL statement to transform. + @return + The new statement with unnamed parameters + */ + OUString transformPreparedStatement(const OUString& _sSQL); + public: Connection(FirebirdDriver* _pDriver); virtual ~Connection(); diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx index ecbb395..b15514c 100644 --- a/connectivity/source/drivers/firebird/Driver.cxx +++ b/connectivity/source/drivers/firebird/Driver.cxx @@ -48,8 +48,7 @@ namespace connectivity const Reference< XMultiServiceFactory >& _rxFactory) throw( Exception ) { SAL_INFO("connectivity.firebird", "FirebirdDriver_CreateInstance()" ); - (void) _rxFactory; - return *(new FirebirdDriver()); + return *(new FirebirdDriver(comphelper::getComponentContext(_rxFactory))); } } } @@ -58,8 +57,9 @@ namespace connectivity const OUString FirebirdDriver::our_sFirebirdTmpVar("FIREBIRD_TMP"); const OUString FirebirdDriver::our_sFirebirdLockVar("FIREBIRD_LOCK"); -FirebirdDriver::FirebirdDriver() +FirebirdDriver::FirebirdDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext) : ODriver_BASE(m_aMutex) + , m_aContext(_rxContext) , m_firebirdTMPDirectory(NULL, true) , m_firebirdLockDirectory(NULL, true) { diff --git a/connectivity/source/drivers/firebird/Driver.hxx b/connectivity/source/drivers/firebird/Driver.hxx index 31c93c6..0c03bac 100644 --- a/connectivity/source/drivers/firebird/Driver.hxx +++ b/connectivity/source/drivers/firebird/Driver.hxx @@ -49,6 +49,7 @@ namespace connectivity static const ::rtl::OUString our_sFirebirdTmpVar; static const ::rtl::OUString our_sFirebirdLockVar; + css::uno::Reference<css::uno::XComponentContext> m_aContext; ::utl::TempFile m_firebirdTMPDirectory; ::utl::TempFile m_firebirdLockDirectory; @@ -60,7 +61,8 @@ namespace connectivity public: - FirebirdDriver(); + FirebirdDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext); + const css::uno::Reference<css::uno::XComponentContext>& getContext() const { return m_aContext; } // OComponentHelper virtual void SAL_CALL disposing(void); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits