1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*caf5cd79SAndrew Rist  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*caf5cd79SAndrew Rist  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19*caf5cd79SAndrew Rist  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir #ifndef _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_
24cdf0e10cSrcweir #define _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "java/lang/Object.hxx"
27cdf0e10cSrcweir #include <com/sun/star/sdbc/XStatement.hpp>
28cdf0e10cSrcweir #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
29cdf0e10cSrcweir #include <com/sun/star/sdbc/XMultipleResults.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sdbc/XBatchExecution.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbc/XCloseable.hpp>
32cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp>
33cdf0e10cSrcweir #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
34cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
35cdf0e10cSrcweir #include <cppuhelper/compbase6.hxx>
36cdf0e10cSrcweir #include <comphelper/uno3.hxx>
37cdf0e10cSrcweir #include "connectivity/CommonTools.hxx"
38cdf0e10cSrcweir #include "OSubComponent.hxx"
39cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
40cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include "java/sql/ConnectionLog.hxx"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir namespace connectivity
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 
47cdf0e10cSrcweir         typedef ::cppu::WeakComponentImplHelper6<       ::com::sun::star::sdbc::XStatement,
48cdf0e10cSrcweir                                                         ::com::sun::star::sdbc::XWarningsSupplier,
49cdf0e10cSrcweir                                                         ::com::sun::star::util::XCancellable,
50cdf0e10cSrcweir                                                         ::com::sun::star::sdbc::XCloseable,
51cdf0e10cSrcweir 														::com::sun::star::sdbc::XGeneratedResultSet,
52cdf0e10cSrcweir                                                         ::com::sun::star::sdbc::XMultipleResults> java_sql_Statement_BASE;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	class java_sql_Connection;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	//**************************************************************
57cdf0e10cSrcweir 	//************ Class: java.sql.Statement
58cdf0e10cSrcweir 	//**************************************************************
59cdf0e10cSrcweir 	class java_sql_Statement_Base : public comphelper::OBaseMutex,
60cdf0e10cSrcweir 									public	java_sql_Statement_BASE,
61cdf0e10cSrcweir 									public	java_lang_Object,
62cdf0e10cSrcweir 									public	::cppu::OPropertySetHelper,
63cdf0e10cSrcweir 									public	::comphelper::OPropertyArrayUsageHelper<java_sql_Statement_Base>
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	{
66cdf0e10cSrcweir 
67cdf0e10cSrcweir         sal_Int32 getQueryTimeOut()             throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
68cdf0e10cSrcweir         sal_Int32 getMaxFieldSize()             throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
69cdf0e10cSrcweir         sal_Int32 getMaxRows()                  throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
70cdf0e10cSrcweir         sal_Int32 getResultSetConcurrency()		throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
71cdf0e10cSrcweir         sal_Int32 getResultSetType()            throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
72cdf0e10cSrcweir         sal_Int32 getFetchDirection()           throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
73cdf0e10cSrcweir         sal_Int32 getFetchSize()                throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
74cdf0e10cSrcweir         ::rtl::OUString getCursorName()         throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
75cdf0e10cSrcweir 
76cdf0e10cSrcweir         void setQueryTimeOut(sal_Int32 _par0)                   throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
77cdf0e10cSrcweir         void setMaxFieldSize(sal_Int32 _par0)                   throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
78cdf0e10cSrcweir         void setMaxRows(sal_Int32 _par0)                                throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
79cdf0e10cSrcweir         void setResultSetConcurrency(sal_Int32 _par0)   throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
80cdf0e10cSrcweir         void setResultSetType(sal_Int32 _par0)                  throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
81cdf0e10cSrcweir         void setFetchDirection(sal_Int32 _par0)                 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
82cdf0e10cSrcweir         void setFetchSize(sal_Int32 _par0)                              throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
83cdf0e10cSrcweir         void setCursorName(const ::rtl::OUString &_par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
84cdf0e10cSrcweir         void setEscapeProcessing(sal_Bool _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	protected:
87cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement>		m_xGeneratedStatement;
88cdf0e10cSrcweir 		java_sql_Connection*	    m_pConnection;
89cdf0e10cSrcweir         java::sql::ConnectionLog    m_aLogger;
90cdf0e10cSrcweir 		::rtl::OUString			    m_sSqlStatement;
91cdf0e10cSrcweir 		// Properties
92cdf0e10cSrcweir 		sal_Int32				    m_nResultSetConcurrency;
93cdf0e10cSrcweir 		sal_Int32				    m_nResultSetType;
94cdf0e10cSrcweir         sal_Bool                    m_bEscapeProcessing;
95cdf0e10cSrcweir         ::cppu::OBroadcastHelper&   rBHelper;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	// statische Daten fuer die Klasse
99cdf0e10cSrcweir 		static jclass theClass;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 		// OPropertyArrayUsageHelper
102cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
103cdf0e10cSrcweir 		// OPropertySetHelper
104cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         virtual sal_Bool SAL_CALL convertFastPropertyValue(
107cdf0e10cSrcweir                                     ::com::sun::star::uno::Any & rConvertedValue,
108cdf0e10cSrcweir                                     ::com::sun::star::uno::Any & rOldValue,
109cdf0e10cSrcweir                                     sal_Int32 nHandle,
110cdf0e10cSrcweir                                     const ::com::sun::star::uno::Any& rValue
111cdf0e10cSrcweir                                 )   throw (::com::sun::star::lang::IllegalArgumentException);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir         virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
114cdf0e10cSrcweir                                     sal_Int32 nHandle,
115cdf0e10cSrcweir                                     const ::com::sun::star::uno::Any& rValue
116cdf0e10cSrcweir                                 )   throw (::com::sun::star::uno::Exception);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         virtual void SAL_CALL getFastPropertyValue(
119cdf0e10cSrcweir                                     ::com::sun::star::uno::Any& rValue,
120cdf0e10cSrcweir                                     sal_Int32 nHandle
121cdf0e10cSrcweir                                 ) const;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 		virtual void createStatement(JNIEnv* _pEnv) = 0;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 		virtual ~java_sql_Statement_Base();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir         sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID);
128cdf0e10cSrcweir         sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     public:
131cdf0e10cSrcweir 		virtual jclass getMyClass() const;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 		// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
134cdf0e10cSrcweir 		java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connection& _rCon );
135cdf0e10cSrcweir 
getStatementObjectID() const136cdf0e10cSrcweir         sal_Int32   getStatementObjectID() const { return m_aLogger.getObjectID(); }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 		// OComponentHelper
139cdf0e10cSrcweir 		virtual void SAL_CALL disposing(void);
140cdf0e10cSrcweir 		// XInterface
141cdf0e10cSrcweir 		virtual void SAL_CALL acquire() throw();
142cdf0e10cSrcweir 		virtual void SAL_CALL release() throw();
143cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
144cdf0e10cSrcweir 		//XTypeProvider
145cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 		// XPropertySet
148cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
149cdf0e10cSrcweir 		// XStatement
150cdf0e10cSrcweir 		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) ;
151cdf0e10cSrcweir 		virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
152cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
153cdf0e10cSrcweir 		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) ;
154cdf0e10cSrcweir 		// XWarningsSupplier
155cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
156cdf0e10cSrcweir 		virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
157cdf0e10cSrcweir 		// XCancellable
158cdf0e10cSrcweir 		virtual void SAL_CALL cancel(  ) throw(::com::sun::star::uno::RuntimeException);
159cdf0e10cSrcweir 		// XCloseable
160cdf0e10cSrcweir 		virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
161cdf0e10cSrcweir 		// XMultipleResults
162cdf0e10cSrcweir 		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);
163cdf0e10cSrcweir 		virtual sal_Int32 SAL_CALL getUpdateCount(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
164cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL getMoreResults(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
165cdf0e10cSrcweir 		//XGeneratedResultSet
166cdf0e10cSrcweir 		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);
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     public:
169cdf0e10cSrcweir         using ::cppu::OPropertySetHelper::getFastPropertyValue;
170cdf0e10cSrcweir 	};
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	class OStatement_BASE2	:public java_sql_Statement_Base
173cdf0e10cSrcweir 							,public OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	{
176cdf0e10cSrcweir 		friend class OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>;
177cdf0e10cSrcweir 	public:
OStatement_BASE2(JNIEnv * pEnv,java_sql_Connection & _rCon)178cdf0e10cSrcweir 		OStatement_BASE2(JNIEnv * pEnv, java_sql_Connection& _rCon ) : java_sql_Statement_Base( pEnv, _rCon ),
179cdf0e10cSrcweir 								OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>((::cppu::OWeakObject*)(&_rCon), this){}
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 		// OComponentHelper
182cdf0e10cSrcweir 		virtual void SAL_CALL disposing(void);
183cdf0e10cSrcweir 		// XInterface
184cdf0e10cSrcweir         virtual void SAL_CALL release() throw();
185cdf0e10cSrcweir 	};
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 	class java_sql_Statement :	public OStatement_BASE2,
188cdf0e10cSrcweir                                 public ::com::sun::star::sdbc::XBatchExecution,
189cdf0e10cSrcweir                                 public ::com::sun::star::lang::XServiceInfo
190cdf0e10cSrcweir 	{
191cdf0e10cSrcweir 	protected:
192cdf0e10cSrcweir 		// statische Daten fuer die Klasse
193cdf0e10cSrcweir 		static jclass theClass;
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 		virtual void createStatement(JNIEnv* _pEnv);
196cdf0e10cSrcweir 
197cdf0e10cSrcweir 		virtual ~java_sql_Statement();
198cdf0e10cSrcweir 	public:
199cdf0e10cSrcweir 		DECLARE_SERVICE_INFO();
200cdf0e10cSrcweir 		virtual jclass getMyClass() const;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 		// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
java_sql_Statement(JNIEnv * pEnv,java_sql_Connection & _rCon)203cdf0e10cSrcweir 		java_sql_Statement( JNIEnv * pEnv, java_sql_Connection& _rCon ) : OStatement_BASE2( pEnv, _rCon){};
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
206cdf0e10cSrcweir 		virtual void SAL_CALL acquire() throw();
207cdf0e10cSrcweir 		virtual void SAL_CALL release() throw();
208cdf0e10cSrcweir 		// XBatchExecution
209cdf0e10cSrcweir 		virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
210cdf0e10cSrcweir 		virtual void SAL_CALL clearBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
211cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
212cdf0e10cSrcweir 	};
213cdf0e10cSrcweir }
214cdf0e10cSrcweir #endif // _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_
215cdf0e10cSrcweir 
216