1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_
28*cdf0e10cSrcweir #define _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "java/lang/Object.hxx"
31*cdf0e10cSrcweir #include <com/sun/star/sdbc/XStatement.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/sdbc/XMultipleResults.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/sdbc/XBatchExecution.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/sdbc/XCloseable.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/util/XCancellable.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
38*cdf0e10cSrcweir #include <comphelper/proparrhlp.hxx>
39*cdf0e10cSrcweir #include <cppuhelper/compbase6.hxx>
40*cdf0e10cSrcweir #include <comphelper/uno3.hxx>
41*cdf0e10cSrcweir #include "connectivity/CommonTools.hxx"
42*cdf0e10cSrcweir #include "OSubComponent.hxx"
43*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
44*cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include "java/sql/ConnectionLog.hxx"
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir namespace connectivity
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir         typedef ::cppu::WeakComponentImplHelper6<       ::com::sun::star::sdbc::XStatement,
52*cdf0e10cSrcweir                                                         ::com::sun::star::sdbc::XWarningsSupplier,
53*cdf0e10cSrcweir                                                         ::com::sun::star::util::XCancellable,
54*cdf0e10cSrcweir                                                         ::com::sun::star::sdbc::XCloseable,
55*cdf0e10cSrcweir 														::com::sun::star::sdbc::XGeneratedResultSet,
56*cdf0e10cSrcweir                                                         ::com::sun::star::sdbc::XMultipleResults> java_sql_Statement_BASE;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 	class java_sql_Connection;
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir 	//**************************************************************
61*cdf0e10cSrcweir 	//************ Class: java.sql.Statement
62*cdf0e10cSrcweir 	//**************************************************************
63*cdf0e10cSrcweir 	class java_sql_Statement_Base : public comphelper::OBaseMutex,
64*cdf0e10cSrcweir 									public	java_sql_Statement_BASE,
65*cdf0e10cSrcweir 									public	java_lang_Object,
66*cdf0e10cSrcweir 									public	::cppu::OPropertySetHelper,
67*cdf0e10cSrcweir 									public	::comphelper::OPropertyArrayUsageHelper<java_sql_Statement_Base>
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 	{
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir         sal_Int32 getQueryTimeOut()             throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
72*cdf0e10cSrcweir         sal_Int32 getMaxFieldSize()             throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
73*cdf0e10cSrcweir         sal_Int32 getMaxRows()                  throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
74*cdf0e10cSrcweir         sal_Int32 getResultSetConcurrency()		throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
75*cdf0e10cSrcweir         sal_Int32 getResultSetType()            throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
76*cdf0e10cSrcweir         sal_Int32 getFetchDirection()           throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
77*cdf0e10cSrcweir         sal_Int32 getFetchSize()                throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
78*cdf0e10cSrcweir         ::rtl::OUString getCursorName()         throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir         void setQueryTimeOut(sal_Int32 _par0)                   throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
81*cdf0e10cSrcweir         void setMaxFieldSize(sal_Int32 _par0)                   throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
82*cdf0e10cSrcweir         void setMaxRows(sal_Int32 _par0)                                throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
83*cdf0e10cSrcweir         void setResultSetConcurrency(sal_Int32 _par0)   throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
84*cdf0e10cSrcweir         void setResultSetType(sal_Int32 _par0)                  throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
85*cdf0e10cSrcweir         void setFetchDirection(sal_Int32 _par0)                 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
86*cdf0e10cSrcweir         void setFetchSize(sal_Int32 _par0)                              throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
87*cdf0e10cSrcweir         void setCursorName(const ::rtl::OUString &_par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
88*cdf0e10cSrcweir         void setEscapeProcessing(sal_Bool _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir 	protected:
91*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement>		m_xGeneratedStatement;
92*cdf0e10cSrcweir 		java_sql_Connection*	    m_pConnection;
93*cdf0e10cSrcweir         java::sql::ConnectionLog    m_aLogger;
94*cdf0e10cSrcweir 		::rtl::OUString			    m_sSqlStatement;
95*cdf0e10cSrcweir 		// Properties
96*cdf0e10cSrcweir 		sal_Int32				    m_nResultSetConcurrency;
97*cdf0e10cSrcweir 		sal_Int32				    m_nResultSetType;
98*cdf0e10cSrcweir         sal_Bool                    m_bEscapeProcessing;
99*cdf0e10cSrcweir         ::cppu::OBroadcastHelper&   rBHelper;
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	// statische Daten fuer die Klasse
103*cdf0e10cSrcweir 		static jclass theClass;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 		// OPropertyArrayUsageHelper
106*cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
107*cdf0e10cSrcweir 		// OPropertySetHelper
108*cdf0e10cSrcweir 		virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         virtual sal_Bool SAL_CALL convertFastPropertyValue(
111*cdf0e10cSrcweir                                     ::com::sun::star::uno::Any & rConvertedValue,
112*cdf0e10cSrcweir                                     ::com::sun::star::uno::Any & rOldValue,
113*cdf0e10cSrcweir                                     sal_Int32 nHandle,
114*cdf0e10cSrcweir                                     const ::com::sun::star::uno::Any& rValue
115*cdf0e10cSrcweir                                 )   throw (::com::sun::star::lang::IllegalArgumentException);
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir         virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
118*cdf0e10cSrcweir                                     sal_Int32 nHandle,
119*cdf0e10cSrcweir                                     const ::com::sun::star::uno::Any& rValue
120*cdf0e10cSrcweir                                 )   throw (::com::sun::star::uno::Exception);
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir         virtual void SAL_CALL getFastPropertyValue(
123*cdf0e10cSrcweir                                     ::com::sun::star::uno::Any& rValue,
124*cdf0e10cSrcweir                                     sal_Int32 nHandle
125*cdf0e10cSrcweir                                 ) const;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 		virtual void createStatement(JNIEnv* _pEnv) = 0;
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 		virtual ~java_sql_Statement_Base();
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir         sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID);
132*cdf0e10cSrcweir         sal_Int32 impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     public:
135*cdf0e10cSrcweir 		virtual jclass getMyClass() const;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 		// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
138*cdf0e10cSrcweir 		java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connection& _rCon );
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir         sal_Int32   getStatementObjectID() const { return m_aLogger.getObjectID(); }
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 		// OComponentHelper
143*cdf0e10cSrcweir 		virtual void SAL_CALL disposing(void);
144*cdf0e10cSrcweir 		// XInterface
145*cdf0e10cSrcweir 		virtual void SAL_CALL acquire() throw();
146*cdf0e10cSrcweir 		virtual void SAL_CALL release() throw();
147*cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
148*cdf0e10cSrcweir 		//XTypeProvider
149*cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 		// XPropertySet
152*cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
153*cdf0e10cSrcweir 		// XStatement
154*cdf0e10cSrcweir 		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) ;
155*cdf0e10cSrcweir 		virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
156*cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
157*cdf0e10cSrcweir 		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) ;
158*cdf0e10cSrcweir 		// XWarningsSupplier
159*cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
160*cdf0e10cSrcweir 		virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
161*cdf0e10cSrcweir 		// XCancellable
162*cdf0e10cSrcweir 		virtual void SAL_CALL cancel(  ) throw(::com::sun::star::uno::RuntimeException);
163*cdf0e10cSrcweir 		// XCloseable
164*cdf0e10cSrcweir 		virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
165*cdf0e10cSrcweir 		// XMultipleResults
166*cdf0e10cSrcweir 		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);
167*cdf0e10cSrcweir 		virtual sal_Int32 SAL_CALL getUpdateCount(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
168*cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL getMoreResults(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
169*cdf0e10cSrcweir 		//XGeneratedResultSet
170*cdf0e10cSrcweir 		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);
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     public:
173*cdf0e10cSrcweir         using ::cppu::OPropertySetHelper::getFastPropertyValue;
174*cdf0e10cSrcweir 	};
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir 	class OStatement_BASE2	:public java_sql_Statement_Base
177*cdf0e10cSrcweir 							,public OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 	{
180*cdf0e10cSrcweir 		friend class OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>;
181*cdf0e10cSrcweir 	public:
182*cdf0e10cSrcweir 		OStatement_BASE2(JNIEnv * pEnv, java_sql_Connection& _rCon ) : java_sql_Statement_Base( pEnv, _rCon ),
183*cdf0e10cSrcweir 								OSubComponent<OStatement_BASE2, java_sql_Statement_BASE>((::cppu::OWeakObject*)(&_rCon), this){}
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 		// OComponentHelper
186*cdf0e10cSrcweir 		virtual void SAL_CALL disposing(void);
187*cdf0e10cSrcweir 		// XInterface
188*cdf0e10cSrcweir         virtual void SAL_CALL release() throw();
189*cdf0e10cSrcweir 	};
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 	class java_sql_Statement :	public OStatement_BASE2,
192*cdf0e10cSrcweir                                 public ::com::sun::star::sdbc::XBatchExecution,
193*cdf0e10cSrcweir                                 public ::com::sun::star::lang::XServiceInfo
194*cdf0e10cSrcweir 	{
195*cdf0e10cSrcweir 	protected:
196*cdf0e10cSrcweir 		// statische Daten fuer die Klasse
197*cdf0e10cSrcweir 		static jclass theClass;
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir 		virtual void createStatement(JNIEnv* _pEnv);
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 		virtual ~java_sql_Statement();
202*cdf0e10cSrcweir 	public:
203*cdf0e10cSrcweir 		DECLARE_SERVICE_INFO();
204*cdf0e10cSrcweir 		virtual jclass getMyClass() const;
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 		// ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
207*cdf0e10cSrcweir 		java_sql_Statement( JNIEnv * pEnv, java_sql_Connection& _rCon ) : OStatement_BASE2( pEnv, _rCon){};
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
210*cdf0e10cSrcweir 		virtual void SAL_CALL acquire() throw();
211*cdf0e10cSrcweir 		virtual void SAL_CALL release() throw();
212*cdf0e10cSrcweir 		// XBatchExecution
213*cdf0e10cSrcweir 		virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
214*cdf0e10cSrcweir 		virtual void SAL_CALL clearBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
215*cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
216*cdf0e10cSrcweir 	};
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir #endif // _CONNECTIVITY_JAVA_SQL_STATEMENT_HXX_
219*cdf0e10cSrcweir 
220