1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * The Contents of this file are made available subject to the terms of 4*cdf0e10cSrcweir * the BSD license. 5*cdf0e10cSrcweir * 6*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 7*cdf0e10cSrcweir * All rights reserved. 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * Redistribution and use in source and binary forms, with or without 10*cdf0e10cSrcweir * modification, are permitted provided that the following conditions 11*cdf0e10cSrcweir * are met: 12*cdf0e10cSrcweir * 1. Redistributions of source code must retain the above copyright 13*cdf0e10cSrcweir * notice, this list of conditions and the following disclaimer. 14*cdf0e10cSrcweir * 2. Redistributions in binary form must reproduce the above copyright 15*cdf0e10cSrcweir * notice, this list of conditions and the following disclaimer in the 16*cdf0e10cSrcweir * documentation and/or other materials provided with the distribution. 17*cdf0e10cSrcweir * 3. Neither the name of Sun Microsystems, Inc. nor the names of its 18*cdf0e10cSrcweir * contributors may be used to endorse or promote products derived 19*cdf0e10cSrcweir * from this software without specific prior written permission. 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22*cdf0e10cSrcweir * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23*cdf0e10cSrcweir * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24*cdf0e10cSrcweir * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25*cdf0e10cSrcweir * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26*cdf0e10cSrcweir * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27*cdf0e10cSrcweir * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28*cdf0e10cSrcweir * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29*cdf0e10cSrcweir * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 30*cdf0e10cSrcweir * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 31*cdf0e10cSrcweir * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32*cdf0e10cSrcweir * 33*cdf0e10cSrcweir *************************************************************************/ 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #ifndef CONNECTIVITY_SSTATEMENT_HXX 36*cdf0e10cSrcweir #define CONNECTIVITY_SSTATEMENT_HXX 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <com/sun/star/sdbc/XStatement.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/sdbc/XWarningsSupplier.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/sdbc/XMultipleResults.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/sdbc/XBatchExecution.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/sdbc/XCloseable.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp> 45*cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx> 46*cdf0e10cSrcweir #include "SConnection.hxx" 47*cdf0e10cSrcweir #include <list> 48*cdf0e10cSrcweir #include "OSubComponent.hxx" 49*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir namespace connectivity 52*cdf0e10cSrcweir { 53*cdf0e10cSrcweir namespace skeleton 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement, 57*cdf0e10cSrcweir ::com::sun::star::sdbc::XWarningsSupplier, 58*cdf0e10cSrcweir ::com::sun::star::util::XCancellable, 59*cdf0e10cSrcweir ::com::sun::star::sdbc::XCloseable, 60*cdf0e10cSrcweir ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir //************************************************************** 63*cdf0e10cSrcweir //************ Class: OStatement_Base 64*cdf0e10cSrcweir // is a base class for the normal statement and for the prepared statement 65*cdf0e10cSrcweir //************************************************************** 66*cdf0e10cSrcweir class OStatement_Base : public OBase_Mutex, 67*cdf0e10cSrcweir public OStatement_BASE, 68*cdf0e10cSrcweir public ::cppu::OPropertySetHelper, 69*cdf0e10cSrcweir public OPropertyArrayUsageHelper<OStatement_Base> 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir ::com::sun::star::sdbc::SQLWarning m_aLastWarning; 73*cdf0e10cSrcweir protected: 74*cdf0e10cSrcweir ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created 75*cdf0e10cSrcweir // for this Statement 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir ::std::list< ::rtl::OUString> m_aBatchList; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir OConnection* m_pConnection; // The owning Connection object 80*cdf0e10cSrcweir protected: 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir void disposeResultSet(); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir // OPropertyArrayUsageHelper 85*cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 86*cdf0e10cSrcweir // OPropertySetHelper 87*cdf0e10cSrcweir virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 88*cdf0e10cSrcweir virtual sal_Bool SAL_CALL convertFastPropertyValue( 89*cdf0e10cSrcweir ::com::sun::star::uno::Any & rConvertedValue, 90*cdf0e10cSrcweir ::com::sun::star::uno::Any & rOldValue, 91*cdf0e10cSrcweir sal_Int32 nHandle, 92*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue ) 93*cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException); 94*cdf0e10cSrcweir virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 95*cdf0e10cSrcweir sal_Int32 nHandle, 96*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception); 97*cdf0e10cSrcweir virtual void SAL_CALL getFastPropertyValue( 98*cdf0e10cSrcweir ::com::sun::star::uno::Any& rValue, 99*cdf0e10cSrcweir sal_Int32 nHandle) const; 100*cdf0e10cSrcweir virtual ~OStatement_Base(); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir public: 103*cdf0e10cSrcweir ::cppu::OBroadcastHelper& rBHelper; 104*cdf0e10cSrcweir OStatement_Base(OConnection* _pConnection ); 105*cdf0e10cSrcweir using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir // OComponentHelper 108*cdf0e10cSrcweir virtual void SAL_CALL disposing(void){OStatement_BASE::disposing();} 109*cdf0e10cSrcweir // XInterface 110*cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 111*cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 112*cdf0e10cSrcweir // XInterface 113*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 114*cdf0e10cSrcweir //XTypeProvider 115*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir // XPropertySet 118*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 119*cdf0e10cSrcweir // XStatement 120*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) ; 121*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; 122*cdf0e10cSrcweir virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; 123*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) ; 124*cdf0e10cSrcweir // XWarningsSupplier 125*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 126*cdf0e10cSrcweir virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 127*cdf0e10cSrcweir // XCancellable 128*cdf0e10cSrcweir virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); 129*cdf0e10cSrcweir // XCloseable 130*cdf0e10cSrcweir virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 131*cdf0e10cSrcweir // XMultipleResults 132*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); 133*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 134*cdf0e10cSrcweir virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir // other methods 137*cdf0e10cSrcweir OConnection* getOwnConnection() const { return m_pConnection;} 138*cdf0e10cSrcweir }; 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir class OStatement_BASE2 :public OStatement_Base 141*cdf0e10cSrcweir ,public OSubComponent<OStatement_BASE2, OStatement_BASE> 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir friend class OSubComponent<OStatement_BASE2, OStatement_BASE>; 145*cdf0e10cSrcweir public: 146*cdf0e10cSrcweir OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ), 147*cdf0e10cSrcweir OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){} 148*cdf0e10cSrcweir // OComponentHelper 149*cdf0e10cSrcweir virtual void SAL_CALL disposing(void); 150*cdf0e10cSrcweir // XInterface 151*cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 152*cdf0e10cSrcweir }; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir class OStatement : public OStatement_BASE2, 155*cdf0e10cSrcweir public ::com::sun::star::sdbc::XBatchExecution, 156*cdf0e10cSrcweir public ::com::sun::star::lang::XServiceInfo 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir protected: 159*cdf0e10cSrcweir virtual ~OStatement(){} 160*cdf0e10cSrcweir public: 161*cdf0e10cSrcweir // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: 162*cdf0e10cSrcweir OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){} 163*cdf0e10cSrcweir DECLARE_SERVICE_INFO(); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 166*cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 167*cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 168*cdf0e10cSrcweir // XBatchExecution 169*cdf0e10cSrcweir virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 170*cdf0e10cSrcweir virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 171*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 172*cdf0e10cSrcweir }; 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir #endif // CONNECTIVITY_SSTATEMENT_HXX 176