1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _CONNECTIVITY_ADO_ASTATEMENT_HXX_ 25 #define _CONNECTIVITY_ADO_ASTATEMENT_HXX_ 26 27 #include <com/sun/star/sdbc/XStatement.hpp> 28 #include <com/sun/star/sdbc/XWarningsSupplier.hpp> 29 #include <com/sun/star/sdbc/XMultipleResults.hpp> 30 #include <com/sun/star/sdbc/XBatchExecution.hpp> 31 #include <com/sun/star/sdbc/XCloseable.hpp> 32 #include <com/sun/star/sdbc/SQLWarning.hpp> 33 #include <com/sun/star/util/XCancellable.hpp> 34 #include <cppuhelper/compbase5.hxx> 35 #include <comphelper/proparrhlp.hxx> 36 #include <comphelper/uno3.hxx> 37 #include <comphelper/broadcasthelper.hxx> 38 #include "ado/AConnection.hxx" 39 #ifndef _LIST_ 40 #include <list> 41 #endif 42 #include "ado/Awrapado.hxx" 43 #include <com/sun/star/lang/XServiceInfo.hpp> 44 45 namespace connectivity 46 { 47 namespace ado 48 { 49 typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement, 50 ::com::sun::star::sdbc::XWarningsSupplier, 51 ::com::sun::star::util::XCancellable, 52 ::com::sun::star::sdbc::XCloseable, 53 ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE; 54 55 //************************************************************** 56 //************ Class: java.sql.Statement 57 //************************************************************** 58 class OStatement_Base : public comphelper::OBaseMutex, 59 public OStatement_BASE, 60 public ::cppu::OPropertySetHelper, 61 public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>, 62 public connectivity::OSubComponent<OStatement_Base, OStatement_BASE> 63 64 { 65 friend class connectivity::OSubComponent<OStatement_Base, OStatement_BASE>; 66 friend class OResultSet; 67 68 ::com::sun::star::sdbc::SQLWarning m_aLastWarning; 69 70 protected: 71 ::std::list< ::rtl::OUString> m_aBatchList; 72 73 ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created 74 // for this Statement 75 76 OConnection* m_pConnection;// The owning Connection object 77 WpADOCommand m_Command; 78 WpADORecordset m_RecordSet; 79 OLEVariant m_RecordsAffected; 80 OLEVariant m_Parameters; 81 ::std::vector<connectivity::OTypeInfo> m_aTypeInfo; // Hashtable containing an entry 82 // for each row returned by 83 // DatabaseMetaData.getTypeInfo. 84 sal_Int32 m_nMaxRows; 85 sal_Int32 m_nFetchSize; 86 LockTypeEnum m_eLockType; 87 CursorTypeEnum m_eCursorType; 88 89 using OStatement_BASE::rBHelper; 90 private: 91 92 sal_Int32 getQueryTimeOut() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 93 sal_Int32 getMaxFieldSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 94 sal_Int32 getMaxRows() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 95 sal_Int32 getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 96 sal_Int32 getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 97 sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 98 sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 99 ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 100 101 void setQueryTimeOut(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 102 void setMaxFieldSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 103 void setMaxRows(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 104 void setResultSetConcurrency(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 105 void setResultSetType(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 106 void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 107 void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 108 void setCursorName(const ::rtl::OUString &_par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 109 110 protected: 111 112 void assignRecordSet( ADORecordset* _pRS ); 113 114 void reset () throw( ::com::sun::star::sdbc::SQLException); 115 void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException); 116 void setWarning (const ::com::sun::star::sdbc::SQLWarning &ex) throw( ::com::sun::star::sdbc::SQLException); 117 sal_Int32 getColumnCount () throw( ::com::sun::star::sdbc::SQLException); 118 sal_Int32 getRowCount () throw( ::com::sun::star::sdbc::SQLException); 119 sal_Int32 getPrecision ( sal_Int32 sqlType); 120 121 void disposeResultSet(); 122 123 // OPropertyArrayUsageHelper 124 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; 125 // OPropertySetHelper 126 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); 127 virtual sal_Bool SAL_CALL convertFastPropertyValue( 128 ::com::sun::star::uno::Any & rConvertedValue, 129 ::com::sun::star::uno::Any & rOldValue, 130 sal_Int32 nHandle, 131 const ::com::sun::star::uno::Any& rValue ) 132 throw (::com::sun::star::lang::IllegalArgumentException); 133 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( 134 sal_Int32 nHandle, 135 const ::com::sun::star::uno::Any& rValue 136 ) 137 throw (::com::sun::star::uno::Exception); 138 virtual void SAL_CALL getFastPropertyValue( 139 ::com::sun::star::uno::Any& rValue, 140 sal_Int32 nHandle 141 ) const; 142 public: 143 OStatement_Base(OConnection* _pConnection ); 144 145 using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; 146 // OComponentHelper 147 virtual void SAL_CALL disposing(void); 148 // XInterface 149 virtual void SAL_CALL acquire() throw(); 150 virtual void SAL_CALL release() throw(); 151 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 152 //XTypeProvider 153 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); 154 155 // XPropertySet 156 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 157 // XStatement 158 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) ; 159 virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; 160 virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ; 161 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) ; 162 // XWarningsSupplier 163 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 164 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 165 // XCancellable 166 virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException); 167 // XCloseable 168 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 169 // XMultipleResults 170 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); 171 virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 172 virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 173 }; 174 175 class OStatement : public OStatement_Base, 176 public ::com::sun::star::sdbc::XBatchExecution, 177 public ::com::sun::star::lang::XServiceInfo 178 { 179 public: 180 // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: OStatement(OConnection * _pConnection)181 OStatement( OConnection* _pConnection) : OStatement_Base( _pConnection){}; 182 ~OStatement(); 183 184 DECLARE_SERVICE_INFO(); 185 186 virtual void SAL_CALL acquire() throw(); 187 virtual void SAL_CALL release() throw(); 188 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); 189 // XBatchExecution 190 virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 191 virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 192 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 193 }; 194 } 195 } 196 #endif // _CONNECTIVITY_ADO_ASTATEMENT_HXX_ 197 198