LibreOffice Module connectivity (master) 1
AStatement.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <com/sun/star/sdbc/XStatement.hpp>
23#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
24#include <com/sun/star/sdbc/XMultipleResults.hpp>
25#include <com/sun/star/sdbc/XBatchExecution.hpp>
26#include <com/sun/star/sdbc/XCloseable.hpp>
27#include <com/sun/star/sdbc/SQLWarning.hpp>
28#include <com/sun/star/util/XCancellable.hpp>
32#include <ado/AConnection.hxx>
33#include <string_view>
34#include <vector>
35#include <ado/Awrapado.hxx>
36#include <com/sun/star/lang/XServiceInfo.hpp>
37
38namespace connectivity::ado
39{
40 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XStatement,
41 css::sdbc::XWarningsSupplier,
42 css::util::XCancellable,
43 css::sdbc::XCloseable,
44 css::sdbc::XMultipleResults> OStatement_BASE;
45
46
47 //************ Class: java.sql.Statement
48
50 public OStatement_BASE,
52 public ::comphelper::OPropertyArrayUsageHelper<OStatement_Base>
53
54 {
55 friend class OResultSet;
56
57 css::sdbc::SQLWarning m_aLastWarning;
58
59 protected:
60 std::vector< OUString> m_aBatchVector;
61
62 css::uno::WeakReference< css::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
63 // for this Statement
64
65 OConnection* m_pConnection;// The owning Connection object
70 std::vector<connectivity::OTypeInfo> m_aTypeInfo; // Hashtable containing an entry
71 // for each row returned by
72 // DatabaseMetaData.getTypeInfo.
73 ADO_LONGPTR m_nMaxRows;
74 sal_Int32 m_nFetchSize;
75 LockTypeEnum m_eLockType;
76 CursorTypeEnum m_eCursorType;
77
78 using OStatement_BASE::rBHelper;
79 private:
82 sal_Int32 getQueryTimeOut() const;
85 static sal_Int32 getMaxFieldSize();
88 sal_Int32 getMaxRows() const;
91 sal_Int32 getResultSetConcurrency() const;
94 sal_Int32 getResultSetType() const;
97 static sal_Int32 getFetchDirection();
100 sal_Int32 getFetchSize() const;
103 OUString getCursorName() const;
104
107 void setQueryTimeOut(sal_Int32 _par0);
110 void setMaxFieldSize(sal_Int32 _par0);
113 void setMaxRows(sal_Int32 _par0);
116 void setResultSetConcurrency(sal_Int32 _par0);
119 void setResultSetType(sal_Int32 _par0);
122 void setFetchDirection(sal_Int32 _par0);
125 void setFetchSize(sal_Int32 _par0);
128 void setCursorName(std::u16string_view _par0);
129
130 protected:
131
132 void assignRecordSet( ADORecordset* _pRS );
133
135 void reset ();
137 void clearMyResultSet ();
139 void setWarning (const css::sdbc::SQLWarning &ex);
141 sal_Int32 getRowCount ();
142 sal_Int32 getPrecision ( sal_Int32 sqlType);
143
144 void disposeResultSet();
145
146 // OPropertyArrayUsageHelper
147 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
148 // OPropertySetHelper
149 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
151 css::uno::Any & rConvertedValue,
152 css::uno::Any & rOldValue,
153 sal_Int32 nHandle,
154 const css::uno::Any& rValue ) override;
155 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
156 sal_Int32 nHandle,
157 const css::uno::Any& rValue
158 ) override;
159 virtual void SAL_CALL getFastPropertyValue(
160 css::uno::Any& rValue,
161 sal_Int32 nHandle
162 ) const override;
163 public:
164 OStatement_Base(OConnection* _pConnection );
165
166 using OStatement_BASE::operator css::uno::Reference< css::uno::XInterface >;
167 // OComponentHelper
168 virtual void SAL_CALL disposing() override;
169 // XInterface
170 virtual void SAL_CALL acquire() noexcept override;
171 virtual void SAL_CALL release() noexcept override;
172 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
173 //XTypeProvider
174 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
175
176 // XPropertySet
177 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
178 // XStatement
179 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) override;
180 virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) override;
181 virtual sal_Bool SAL_CALL execute( const OUString& sql ) override;
182 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override;
183 // XWarningsSupplier
184 virtual css::uno::Any SAL_CALL getWarnings( ) override;
185 virtual void SAL_CALL clearWarnings( ) override;
186 // XCancellable
187 virtual void SAL_CALL cancel( ) override;
188 // XCloseable
189 virtual void SAL_CALL close( ) override;
190 // XMultipleResults
191 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override;
192 virtual sal_Int32 SAL_CALL getUpdateCount( ) override;
193 virtual sal_Bool SAL_CALL getMoreResults( ) override;
194 };
195
197 public css::sdbc::XBatchExecution,
198 public css::lang::XServiceInfo
199 {
200 public:
201 // a Constructor, that is needed for when Returning the Object is needed:
202 OStatement( OConnection* _pConnection) : OStatement_Base( _pConnection){};
203 ~OStatement() override;
204
206
207 virtual void SAL_CALL acquire() noexcept override;
208 virtual void SAL_CALL release() noexcept override;
209 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
210 // XBatchExecution
211 virtual void SAL_CALL addBatch( const OUString& sql ) override;
212 virtual void SAL_CALL clearBatch( ) override;
213 virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) override;
214 };
215}
216
217/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL cancel() override
Definition: AStatement.cxx:131
std::vector< connectivity::OTypeInfo > m_aTypeInfo
Definition: AStatement.hxx:70
sal_Int32 getResultSetConcurrency() const
Definition: AStatement.cxx:499
void setQueryTimeOut(sal_Int32 _par0)
Definition: AStatement.cxx:556
sal_Int32 getPrecision(sal_Int32 sqlType)
Definition: AStatement.cxx:205
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual void SAL_CALL acquire() noexcept override
Definition: AStatement.cxx:847
css::uno::WeakReference< css::sdbc::XResultSet > m_xResultSet
Definition: AStatement.hxx:62
void setCursorName(std::u16string_view _par0)
Definition: AStatement.cxx:632
void setResultSetType(sal_Int32 _par0)
Definition: AStatement.cxx:589
void assignRecordSet(ADORecordset *_pRS)
Definition: AStatement.cxx:239
void setMaxFieldSize(sal_Int32 _par0)
Definition: AStatement.cxx:625
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
Definition: AStatement.cxx:317
virtual sal_Bool SAL_CALL execute(const OUString &sql) override
Definition: AStatement.cxx:251
static sal_Int32 getFetchDirection()
Definition: AStatement.cxx:536
virtual sal_Int32 SAL_CALL executeUpdate(const OUString &sql) override
Definition: AStatement.cxx:387
virtual sal_Int32 SAL_CALL getUpdateCount() override
Definition: AStatement.cxx:424
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
void setResultSetConcurrency(sal_Int32 _par0)
Definition: AStatement.cxx:573
void setMaxRows(sal_Int32 _par0)
Definition: AStatement.cxx:565
void setWarning(const css::sdbc::SQLWarning &ex)
virtual void SAL_CALL close() override
Definition: AStatement.cxx:141
css::sdbc::SQLWarning m_aLastWarning
Definition: AStatement.hxx:57
virtual void SAL_CALL clearWarnings() override
Definition: AStatement.cxx:476
virtual css::uno::Any SAL_CALL getWarnings() override
Definition: AStatement.cxx:466
void setFetchDirection(sal_Int32 _par0)
Definition: AStatement.cxx:609
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: AStatement.cxx:121
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: AStatement.cxx:711
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet() override
Definition: AStatement.cxx:414
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual sal_Bool SAL_CALL getMoreResults() override
Definition: AStatement.cxx:437
virtual void SAL_CALL disposing() override
Definition: AStatement.cxx:89
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: AStatement.cxx:862
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
Definition: AStatement.cxx:641
static sal_Int32 getMaxFieldSize()
Definition: AStatement.cxx:546
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(const OUString &sql) override
Definition: AStatement.cxx:281
void setFetchSize(sal_Int32 _par0)
Definition: AStatement.cxx:616
OStatement_Base(OConnection *_pConnection)
Definition: AStatement.cxx:55
virtual void SAL_CALL release() noexcept override
Definition: AStatement.cxx:110
std::vector< OUString > m_aBatchVector
Definition: AStatement.hxx:60
OStatement(OConnection *_pConnection)
Definition: AStatement.hxx:202
Type
::cppu::WeakComponentImplHelper< css::sdbc::XStatement, css::sdbc::XWarningsSupplier, css::util::XCancellable, css::sdbc::XCloseable, css::sdbc::XMultipleResults > OStatement_BASE
Definition: AStatement.hxx:44
unsigned char sal_Bool