cid#1607171 Data race condition
[LibreOffice.git] / connectivity / source / inc / java / sql / JStatement.hxx
blob89a091bd96a78904d6af6a630364eb219a776eb2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include <java/lang/Object.hxx>
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/util/XCancellable.hpp>
28 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
29 #include <comphelper/proparrhlp.hxx>
30 #include <cppuhelper/compbase.hxx>
31 #include <cppuhelper/basemutex.hxx>
32 #include <connectivity/CommonTools.hxx>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <java/sql/Connection.hxx>
36 #include <java/sql/ConnectionLog.hxx>
38 namespace connectivity
41 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XStatement,
42 css::sdbc::XWarningsSupplier,
43 css::util::XCancellable,
44 css::sdbc::XCloseable,
45 css::sdbc::XGeneratedResultSet,
46 css::sdbc::XMultipleResults> java_sql_Statement_BASE;
48 //************ Class: java.sql.Statement
50 class java_sql_Statement_Base : public cppu::BaseMutex,
51 public java_sql_Statement_BASE,
52 public java_lang_Object,
53 public ::cppu::OPropertySetHelper,
54 public ::comphelper::OPropertyArrayUsageHelper<java_sql_Statement_Base>
58 /// @throws css::sdbc::SQLException
59 /// @throws css::uno::RuntimeException
60 sal_Int32 getQueryTimeOut();
61 /// @throws css::sdbc::SQLException
62 /// @throws css::uno::RuntimeException
63 sal_Int32 getMaxFieldSize();
64 /// @throws css::sdbc::SQLException
65 /// @throws css::uno::RuntimeException
66 sal_Int32 getMaxRows();
67 /// @throws css::sdbc::SQLException
68 /// @throws css::uno::RuntimeException
69 sal_Int32 getResultSetConcurrency();
70 /// @throws css::sdbc::SQLException
71 /// @throws css::uno::RuntimeException
72 sal_Int32 getResultSetType();
73 /// @throws css::sdbc::SQLException
74 /// @throws css::uno::RuntimeException
75 sal_Int32 getFetchDirection();
76 /// @throws css::sdbc::SQLException
77 /// @throws css::uno::RuntimeException
78 sal_Int32 getFetchSize();
79 /// @throws css::sdbc::SQLException
80 /// @throws css::uno::RuntimeException
81 OUString getCursorName();
83 /// @throws css::sdbc::SQLException
84 /// @throws css::uno::RuntimeException
85 void setQueryTimeOut(sal_Int32 _par0);
86 /// @throws css::sdbc::SQLException
87 /// @throws css::uno::RuntimeException
88 void setMaxFieldSize(sal_Int32 _par0);
89 /// @throws css::sdbc::SQLException
90 /// @throws css::uno::RuntimeException
91 void setMaxRows(sal_Int32 _par0);
92 /// @throws css::sdbc::SQLException
93 /// @throws css::uno::RuntimeException
94 void setResultSetConcurrency(sal_Int32 _par0);
95 /// @throws css::sdbc::SQLException
96 /// @throws css::uno::RuntimeException
97 void setResultSetType(sal_Int32 _par0);
98 /// @throws css::sdbc::SQLException
99 /// @throws css::uno::RuntimeException
100 void setFetchDirection(sal_Int32 _par0);
101 /// @throws css::sdbc::SQLException
102 /// @throws css::uno::RuntimeException
103 void setFetchSize(sal_Int32 _par0);
104 /// @throws css::sdbc::SQLException
105 /// @throws css::uno::RuntimeException
106 void setCursorName(const OUString &_par0);
107 /// @throws css::sdbc::SQLException
108 /// @throws css::uno::RuntimeException
109 void setEscapeProcessing(bool _par0);
111 protected:
112 css::uno::Reference< css::sdbc::XStatement> m_xGeneratedStatement;
113 rtl::Reference<java_sql_Connection> m_pConnection;
114 java::sql::ConnectionLog m_aLogger;
115 OUString m_sSqlStatement;
116 // Properties
117 sal_Int32 m_nResultSetConcurrency;
118 sal_Int32 m_nResultSetType;
119 bool m_bEscapeProcessing;
122 // Static data for the class
123 static jclass theClass;
125 // OPropertyArrayUsageHelper
126 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
127 // OPropertySetHelper
128 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
130 virtual sal_Bool SAL_CALL convertFastPropertyValue(
131 css::uno::Any & rConvertedValue,
132 css::uno::Any & rOldValue,
133 sal_Int32 nHandle,
134 const css::uno::Any& rValue
135 ) override;
137 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
138 sal_Int32 nHandle,
139 const css::uno::Any& rValue
140 ) override;
142 virtual void SAL_CALL getFastPropertyValue(
143 css::uno::Any& rValue,
144 sal_Int32 nHandle
145 ) const override;
147 virtual void createStatement(JNIEnv* _pEnv) = 0;
149 virtual ~java_sql_Statement_Base() override;
151 sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID);
152 sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault);
154 public:
155 virtual jclass getMyClass() const override;
157 // A ctor that is needed for returning the object
158 java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connection& _rCon );
160 sal_Int32 getStatementObjectID() const { return m_aLogger.getObjectID(); }
162 // OComponentHelper
163 virtual void SAL_CALL disposing() override;
164 // XInterface
165 virtual void SAL_CALL acquire() noexcept override;
166 virtual void SAL_CALL release() noexcept override;
167 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
168 //XTypeProvider
169 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
171 // XPropertySet
172 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
173 // XStatement
174 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) override ;
175 virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) override ;
176 virtual sal_Bool SAL_CALL execute( const OUString& sql ) override ;
177 virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection( ) override ;
178 // XWarningsSupplier
179 virtual css::uno::Any SAL_CALL getWarnings( ) override;
180 virtual void SAL_CALL clearWarnings( ) override;
181 // XCancellable
182 virtual void SAL_CALL cancel( ) override;
183 // XCloseable
184 virtual void SAL_CALL close( ) override;
185 // XMultipleResults
186 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet( ) override;
187 virtual sal_Int32 SAL_CALL getUpdateCount( ) override;
188 virtual sal_Bool SAL_CALL getMoreResults( ) override;
189 //XGeneratedResultSet
190 virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) override;
192 public:
193 using ::cppu::OPropertySetHelper::getFastPropertyValue;
196 class OStatement_BASE2 : public java_sql_Statement_Base
199 public:
200 OStatement_BASE2(JNIEnv * pEnv, java_sql_Connection& _rCon ) : java_sql_Statement_Base( pEnv, _rCon ) {}
202 // OComponentHelper
203 virtual void SAL_CALL disposing() override;
206 class java_sql_Statement : public OStatement_BASE2,
207 public css::sdbc::XBatchExecution,
208 public css::lang::XServiceInfo
210 protected:
211 // Static data for the class
212 static jclass theClass;
214 virtual void createStatement(JNIEnv* _pEnv) override;
216 virtual ~java_sql_Statement() override;
217 public:
218 DECLARE_SERVICE_INFO();
219 virtual jclass getMyClass() const override;
221 // A ctor that is needed for returning the object
222 java_sql_Statement( JNIEnv * pEnv, java_sql_Connection& _rCon ) : OStatement_BASE2( pEnv, _rCon){};
224 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
225 virtual void SAL_CALL acquire() noexcept override;
226 virtual void SAL_CALL release() noexcept override;
227 // XBatchExecution
228 virtual void SAL_CALL addBatch( const OUString& sql ) override;
229 virtual void SAL_CALL clearBatch( ) override;
230 virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) override;
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */