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