Line data Source code
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 : #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_JSTATEMENT_HXX
20 : #define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_JSTATEMENT_HXX
21 :
22 : #include "java/lang/Object.hxx"
23 : #include <com/sun/star/sdbc/XStatement.hpp>
24 : #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
25 : #include <com/sun/star/sdbc/XMultipleResults.hpp>
26 : #include <com/sun/star/sdbc/XBatchExecution.hpp>
27 : #include <com/sun/star/sdbc/XCloseable.hpp>
28 : #include <com/sun/star/util/XCancellable.hpp>
29 : #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
30 : #include <comphelper/proparrhlp.hxx>
31 : #include <cppuhelper/compbase6.hxx>
32 : #include <comphelper/uno3.hxx>
33 : #include <connectivity/CommonTools.hxx>
34 : #include <connectivity/OSubComponent.hxx>
35 : #include <com/sun/star/lang/XServiceInfo.hpp>
36 : #include <comphelper/broadcasthelper.hxx>
37 :
38 : #include "java/sql/ConnectionLog.hxx"
39 :
40 : namespace connectivity
41 : {
42 :
43 : typedef ::cppu::WeakComponentImplHelper6< ::com::sun::star::sdbc::XStatement,
44 : ::com::sun::star::sdbc::XWarningsSupplier,
45 : ::com::sun::star::util::XCancellable,
46 : ::com::sun::star::sdbc::XCloseable,
47 : ::com::sun::star::sdbc::XGeneratedResultSet,
48 : ::com::sun::star::sdbc::XMultipleResults> java_sql_Statement_BASE;
49 :
50 : class java_sql_Connection;
51 :
52 :
53 : //************ Class: java.sql.Statement
54 :
55 : class java_sql_Statement_Base : public comphelper::OBaseMutex,
56 : public java_sql_Statement_BASE,
57 : public java_lang_Object,
58 : public ::cppu::OPropertySetHelper,
59 : public ::comphelper::OPropertyArrayUsageHelper<java_sql_Statement_Base>
60 :
61 : {
62 :
63 : sal_Int32 getQueryTimeOut() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
64 : sal_Int32 getMaxFieldSize() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
65 : sal_Int32 getMaxRows() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
66 : sal_Int32 getResultSetConcurrency() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
67 : sal_Int32 getResultSetType() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
68 : sal_Int32 getFetchDirection() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
69 : sal_Int32 getFetchSize() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
70 : OUString getCursorName() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
71 :
72 : void setQueryTimeOut(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
73 : void setMaxFieldSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
74 : void setMaxRows(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
75 : void setResultSetConcurrency(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
76 : void setResultSetType(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
77 : void setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
78 : void setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
79 : void setCursorName(const OUString &_par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
80 : void setEscapeProcessing(bool _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
81 :
82 : protected:
83 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement> m_xGeneratedStatement;
84 : java_sql_Connection* m_pConnection;
85 : java::sql::ConnectionLog m_aLogger;
86 : OUString m_sSqlStatement;
87 : // Properties
88 : sal_Int32 m_nResultSetConcurrency;
89 : sal_Int32 m_nResultSetType;
90 : bool m_bEscapeProcessing;
91 : ::cppu::OBroadcastHelper& rBHelper;
92 :
93 :
94 : // Static data for the class
95 : static jclass theClass;
96 :
97 : // OPropertyArrayUsageHelper
98 : virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
99 : // OPropertySetHelper
100 : virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
101 :
102 : virtual sal_Bool SAL_CALL convertFastPropertyValue(
103 : ::com::sun::star::uno::Any & rConvertedValue,
104 : ::com::sun::star::uno::Any & rOldValue,
105 : sal_Int32 nHandle,
106 : const ::com::sun::star::uno::Any& rValue
107 : ) throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
108 :
109 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
110 : sal_Int32 nHandle,
111 : const ::com::sun::star::uno::Any& rValue
112 : ) throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
113 :
114 : virtual void SAL_CALL getFastPropertyValue(
115 : ::com::sun::star::uno::Any& rValue,
116 : sal_Int32 nHandle
117 : ) const SAL_OVERRIDE;
118 :
119 : virtual void createStatement(JNIEnv* _pEnv) = 0;
120 :
121 : virtual ~java_sql_Statement_Base();
122 :
123 : sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID);
124 : sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault);
125 :
126 : public:
127 : virtual jclass getMyClass() const SAL_OVERRIDE;
128 :
129 : // A ctor that is needed for returning the object
130 : java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connection& _rCon );
131 :
132 6 : sal_Int32 getStatementObjectID() const { return m_aLogger.getObjectID(); }
133 :
134 : // OComponentHelper
135 : virtual void SAL_CALL disposing(void) SAL_OVERRIDE;
136 : // XInterface
137 : virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
138 : virtual void SAL_CALL release() throw() SAL_OVERRIDE;
139 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 : //XTypeProvider
141 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 :
143 : // XPropertySet
144 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
145 : // XStatement
146 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
147 : virtual sal_Int32 SAL_CALL executeUpdate( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
148 : virtual sal_Bool SAL_CALL execute( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
149 : 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, std::exception) SAL_OVERRIDE ;
150 : // XWarningsSupplier
151 : virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
152 : virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
153 : // XCancellable
154 : virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 : // XCloseable
156 : virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
157 : // XMultipleResults
158 : 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, std::exception) SAL_OVERRIDE;
159 : virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
160 : virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
161 : //XGeneratedResultSet
162 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getGeneratedValues( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
163 :
164 : public:
165 : using ::cppu::OPropertySetHelper::getFastPropertyValue;
166 : };
167 :
168 6 : class OStatement_BASE2 :public java_sql_Statement_Base
169 : ,public OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>
170 :
171 : {
172 : friend class OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>;
173 : public:
174 6 : OStatement_BASE2(JNIEnv * pEnv, java_sql_Connection& _rCon ) : java_sql_Statement_Base( pEnv, _rCon ),
175 6 : OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>((::cppu::OWeakObject*)(&_rCon), this){}
176 :
177 : // OComponentHelper
178 : virtual void SAL_CALL disposing(void) SAL_OVERRIDE;
179 : // XInterface
180 : virtual void SAL_CALL release() throw() SAL_OVERRIDE;
181 : };
182 :
183 : class java_sql_Statement : public OStatement_BASE2,
184 : public ::com::sun::star::sdbc::XBatchExecution,
185 : public ::com::sun::star::lang::XServiceInfo
186 : {
187 : protected:
188 : // Static data for the class
189 : static jclass theClass;
190 :
191 : virtual void createStatement(JNIEnv* _pEnv) SAL_OVERRIDE;
192 :
193 : virtual ~java_sql_Statement();
194 : public:
195 : DECLARE_SERVICE_INFO();
196 : virtual jclass getMyClass() const SAL_OVERRIDE;
197 :
198 : // A ctor that is needed for returning the object
199 6 : java_sql_Statement( JNIEnv * pEnv, java_sql_Connection& _rCon ) : OStatement_BASE2( pEnv, _rCon){};
200 :
201 : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
202 : virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
203 : virtual void SAL_CALL release() throw() SAL_OVERRIDE;
204 : // XBatchExecution
205 : virtual void SAL_CALL addBatch( const OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
206 : virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
207 : virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
208 : };
209 : }
210 : #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_JSTATEMENT_HXX
211 :
212 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|