diff options
Diffstat (limited to 'connectivity/source/drivers/ado/APreparedStatement.cxx')
-rw-r--r-- | connectivity/source/drivers/ado/APreparedStatement.cxx | 71 |
1 files changed, 19 insertions, 52 deletions
diff --git a/connectivity/source/drivers/ado/APreparedStatement.cxx b/connectivity/source/drivers/ado/APreparedStatement.cxx index 34697fa4388a..d7c82d184fdb 100644 --- a/connectivity/source/drivers/ado/APreparedStatement.cxx +++ b/connectivity/source/drivers/ado/APreparedStatement.cxx @@ -31,13 +31,14 @@ #include <comphelper/types.hxx> #include <connectivity/dbexception.hxx> #include <connectivity/dbtools.hxx> +#include <rtl/ref.hxx> #include <strings.hrc> #include <limits> #define CHECK_RETURN(x) \ if(!x) \ - ADOS::ThrowException(*m_pConnection->getConnection(),*this); + ADOS::ThrowException(m_pConnection->getConnection(),*this); #ifdef max # undef max @@ -54,7 +55,7 @@ using namespace com::sun::star::util; IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.APreparedStatement","com.sun.star.sdbc.PreparedStatement"); OPreparedStatement::OPreparedStatement( OConnection* _pConnection, const OUString& sql) - : OStatement_Base( _pConnection ) + : OPreparedStatement_BASE(_pConnection) { osl_atomic_increment( &m_refCount ); @@ -91,24 +92,6 @@ OPreparedStatement::~OPreparedStatement() } } -Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) -{ - Any aRet = OStatement_Base::queryInterface(rType); - return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType, - static_cast< XPreparedStatement*>(this), - static_cast< XParameters*>(this), - static_cast< XResultSetMetaDataSupplier*>(this)); -} - -css::uno::Sequence< css::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) -{ - ::cppu::OTypeCollection aTypes( cppu::UnoType<XPreparedStatement>::get(), - cppu::UnoType<XParameters>::get(), - cppu::UnoType<XResultSetMetaDataSupplier>::get()); - - return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_Base::getTypes()); -} - Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) { if(!m_xMetaData.is() && m_RecordSet.IsValid()) @@ -144,21 +127,18 @@ sal_Bool SAL_CALL OPreparedStatement::execute( ) ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OStatement_BASE::rBHelper.bDisposed); - SQLWarning warning; clearWarnings (); // Call SQLExecute try { ADORecordset* pSet=nullptr; CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdUnknown,&pSet)) - m_RecordSet = WpADORecordset(pSet); + m_RecordSet.set(pSet); } - catch (SQLWarning& ex) + catch (SQLWarning&) { - // Save pointer to warning and save with ResultSet + //TODO: Save pointer to warning and save with ResultSet // object once it is created. - - warning = ex; } return m_RecordSet.IsValid(); } @@ -173,11 +153,11 @@ sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdUnknown,&pSet)) if ( VT_ERROR == m_RecordsAffected.getType() ) { - ADOS::ThrowException(*m_pConnection->getConnection(),*this); + ADOS::ThrowException(m_pConnection->getConnection(),*this); // to be sure that we get the error really thrown throw SQLException(); } - m_RecordSet = WpADORecordset(pSet); + m_RecordSet.set(pSet); return m_RecordsAffected.getInt32(); } @@ -201,10 +181,9 @@ void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const DataTypeEn } else { - ADOParameter* pParam = nullptr; - m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam); - WpADOParameter aParam(pParam); - if(pParam) + WpADOParameter aParam; + m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&aParam); + if(aParam) { DataTypeEnum eType = aParam.GetADOType(); if ( _eType != eType && _eType != adDBTimeStamp ) @@ -222,7 +201,7 @@ void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const DataTypeEn CHECK_RETURN(aParam.PutValue(Val)); } } - ADOS::ThrowException(*m_pConnection->getConnection(),*this); + ADOS::ThrowException(m_pConnection->getConnection(),*this); } void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const OUString& x ) @@ -264,13 +243,12 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) CHECK_RETURN(m_RecordSet.get_CursorType(m_eCursorType)) CHECK_RETURN(m_RecordSet.get_LockType(m_eLockType)) - OResultSet* pSet = new OResultSet(m_RecordSet,this); - Reference< XResultSet > xRs = pSet; + rtl::Reference<OResultSet> pSet = new OResultSet(m_RecordSet,this); pSet->construct(); pSet->setMetaData(getMetaData()); - m_xResultSet = WeakReference<XResultSet>(xRs); + m_xResultSet = pSet.get(); - return xRs; + return pSet; } void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) @@ -415,10 +393,9 @@ void SAL_CALL OPreparedStatement::clearParameters( ) aVal.setEmpty(); for(sal_Int32 i=0;i<nCount;++i) { - ADOParameter* pParam = nullptr; - m_pParameters->get_Item(OLEVariant(i),&pParam); - WpADOParameter aParam(pParam); - if(pParam) + WpADOParameter aParam; + m_pParameters->get_Item(OLEVariant(i),&aParam); + if(aParam) { CHECK_RETURN(aParam.PutValue(aVal)); } @@ -426,16 +403,6 @@ void SAL_CALL OPreparedStatement::clearParameters( ) } } -void SAL_CALL OPreparedStatement::acquire() throw() -{ - OStatement_Base::acquire(); -} - -void SAL_CALL OPreparedStatement::release() throw() -{ - OStatement_Base::release(); -} - void OPreparedStatement::replaceParameterNodeName(OSQLParseNode const * _pNode, const OUString& _sDefaultName, sal_Int32& _rParameterCount) @@ -447,7 +414,7 @@ void OPreparedStatement::replaceParameterNodeName(OSQLParseNode const * _pNode, if(SQL_ISRULE(pChildNode,parameter) && pChildNode->count() == 1) { OSQLParseNode* pNewNode = new OSQLParseNode(OUString(":") ,SQLNodeType::Punctuation,0); - delete pChildNode->replace(pChildNode->getChild(0),pNewNode); + pChildNode->replaceAndDelete(pChildNode->getChild(0), pNewNode); OUString sParameterName = _sDefaultName + OUString::number(++_rParameterCount); pChildNode->append(new OSQLParseNode( sParameterName,SQLNodeType::Name,0)); } |