1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _CONNECTIVITY_ADO_ASTATEMENT_HXX_ 29*cdf0e10cSrcweir #define _CONNECTIVITY_ADO_ASTATEMENT_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/sdbc/XStatement.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/sdbc/XWarningsSupplier.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/sdbc/XMultipleResults.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/sdbc/XBatchExecution.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/sdbc/XCloseable.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp> 38*cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx> 39*cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx> 40*cdf0e10cSrcweir #include <comphelper/uno3.hxx> 41*cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 42*cdf0e10cSrcweir #include "ado/AConnection.hxx" 43*cdf0e10cSrcweir #ifndef _LIST_ 44*cdf0e10cSrcweir #include <list> 45*cdf0e10cSrcweir #endif 46*cdf0e10cSrcweir #include "ado/Awrapado.hxx" 47*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir namespace connectivity 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir namespace ado 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement, 54*cdf0e10cSrcweir ::com::sun::star::sdbc::XWarningsSupplier, 55*cdf0e10cSrcweir ::com::sun::star::util::XCancellable, 56*cdf0e10cSrcweir ::com::sun::star::sdbc::XCloseable, 57*cdf0e10cSrcweir ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE; 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir //************************************************************** 60*cdf0e10cSrcweir //************ Class: java.sql.Statement 61*cdf0e10cSrcweir //************************************************************** 62*cdf0e10cSrcweir class OStatement_Base : public comphelper::OBaseMutex, 63*cdf0e10cSrcweir public OStatement_BASE, 64*cdf0e10cSrcweir public ::cppu::OPropertySetHelper, 65*cdf0e10cSrcweir public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>, 66*cdf0e10cSrcweir public connectivity::OSubComponent<OStatement_Base, OStatement_BASE> 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir friend class connectivity::OSubComponent<OStatement_Base, OStatement_BASE>; 70*cdf0e10cSrcweir friend class OResultSet; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir ::com::sun::star::sdbc::SQLWarning m_aLastWarning; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir protected: 75*cdf0e10cSrcweir ::std::list< ::rtl::OUString> m_aBatchList; 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created 78*cdf0e10cSrcweir // for this Statement 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir OConnection* m_pConnection;// The owning Connection object 81*cdf0e10cSrcweir WpADOCommand m_Command; 82*cdf0e10cSrcweir WpADORecordset m_RecordSet; 83*cdf0e10cSrcweir OLEVariant m_RecordsAffected; 84*cdf0e10cSrcweir OLEVariant m_Parameters; 85*cdf0e10cSrcweir ::std::vector<connectivity::OTypeInfo> m_aTypeInfo; // Hashtable containing an entry 86*cdf0e10cSrcweir // for each row returned by 87*cdf0e10cSrcweir // DatabaseMetaData.getTypeInfo. 88*cdf0e10cSrcweir sal_Int32 m_nMaxRows; 89*cdf0e10cSrcweir sal_Int32 m_nFetchSize; 90*cdf0e10cSrcweir LockTypeEnum m_eLockType; 91*cdf0e10cSrcweir CursorTypeEnum m_eCursorType; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir using OStatement_BASE::rBHelper; 94*cdf0e10cSrcweir private: 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir sal_Int32 getQueryTimeOut() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 97*cdf0e10cSrcweir sal_Int32 getMaxFieldSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 98*cdf0e10cSrcweir sal_Int32 getMaxRows() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 99*cdf0e10cSrcweir sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 100*cdf0e10cSrcweir sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 101*cdf0e10cSrcweir sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 102*cdf0e10cSrcweir sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 103*cdf0e10cSrcweir ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir void setQueryTimeOut(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 106*cdf0e10cSrcweir void setMaxFieldSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 107*cdf0e10cSrcweir void setMaxRows(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 108*cdf0e10cSrcweir void setResultSetConcurrency(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 109*cdf0e10cSrcweir void setResultSetType(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 110*cdf0e10cSrcweir void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 111*cdf0e10cSrcweir void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 112*cdf0e10cSrcweir void setCursorName(const ::rtl::OUString &_par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir protected: 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir void assignRecordSet( ADORecordset* _pRS ); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir void reset () throw( ::com::sun::star::sdbc::SQLException); 119*cdf0e10cSrcweir void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException); 120*cdf0e10cSrcweir void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException); 121*cdf0e10cSrcweir sal_Int32 getColumnCount () throw( ::com::sun::star::sdbc::SQLException); 122*cdf0e10cSrcweir sal_Int32 getRowCount () throw( ::com::sun::star::sdbc::SQLException); 123*cdf0e10cSrcweir sal_Int32 getPrecision ( sal_Int32 sqlType); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir void disposeResultSet(); 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir // OPropertyArrayUsageHelper 128*cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 129*cdf0e10cSrcweir // OPropertySetHelper 130*cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 131*cdf0e10cSrcweir virtual sal_Bool SAL_CALL convertFastPropertyValue( 132*cdf0e10cSrcweir ::com::sun::star::uno::Any & rConvertedValue, 133*cdf0e10cSrcweir ::com::sun::star::uno::Any & rOldValue, 134*cdf0e10cSrcweir sal_Int32 nHandle, 135*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue ) 136*cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException); 137*cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 138*cdf0e10cSrcweir sal_Int32 nHandle, 139*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue 140*cdf0e10cSrcweir ) 141*cdf0e10cSrcweir throw (::com::sun::star::uno::Exception); 142*cdf0e10cSrcweir virtual void SAL_CALL getFastPropertyValue( 143*cdf0e10cSrcweir ::com::sun::star::uno::Any& rValue, 144*cdf0e10cSrcweir sal_Int32 nHandle 145*cdf0e10cSrcweir ) const; 146*cdf0e10cSrcweir public: 147*cdf0e10cSrcweir OStatement_Base(OConnection* _pConnection ); 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; 150*cdf0e10cSrcweir // OComponentHelper 151*cdf0e10cSrcweir virtual void SAL_CALL disposing(void); 152*cdf0e10cSrcweir // XInterface 153*cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 154*cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 155*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 156*cdf0e10cSrcweir //XTypeProvider 157*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir // XPropertySet 160*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 161*cdf0e10cSrcweir // XStatement 162*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; 163*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; 164*cdf0e10cSrcweir virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; 165*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; 166*cdf0e10cSrcweir // XWarningsSupplier 167*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 168*cdf0e10cSrcweir virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 169*cdf0e10cSrcweir // XCancellable 170*cdf0e10cSrcweir virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); 171*cdf0e10cSrcweir // XCloseable 172*cdf0e10cSrcweir virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 173*cdf0e10cSrcweir // XMultipleResults 174*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 175*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 176*cdf0e10cSrcweir virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 177*cdf0e10cSrcweir }; 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir class OStatement : public OStatement_Base, 180*cdf0e10cSrcweir public ::com::sun::star::sdbc::XBatchExecution, 181*cdf0e10cSrcweir public ::com::sun::star::lang::XServiceInfo 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir public: 184*cdf0e10cSrcweir // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: 185*cdf0e10cSrcweir OStatement( OConnection* _pConnection) : OStatement_Base( _pConnection){}; 186*cdf0e10cSrcweir ~OStatement(); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir DECLARE_SERVICE_INFO(); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 191*cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 192*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 193*cdf0e10cSrcweir // XBatchExecution 194*cdf0e10cSrcweir virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 195*cdf0e10cSrcweir virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 196*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 197*cdf0e10cSrcweir }; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir #endif // _CONNECTIVITY_ADO_ASTATEMENT_HXX_ 201*cdf0e10cSrcweir 202