1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9b5730f6SAndrew Rist  * distributed with this work for additional information
6*9b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9b5730f6SAndrew Rist  *
11*9b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9b5730f6SAndrew Rist  *
13*9b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist  * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9b5730f6SAndrew Rist  * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist  * under the License.
19*9b5730f6SAndrew Rist  *
20*9b5730f6SAndrew Rist  *************************************************************/
21*9b5730f6SAndrew Rist 
22*9b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "java/sql/JStatement.hxx"
28cdf0e10cSrcweir #include "java/sql/ResultSet.hxx"
29cdf0e10cSrcweir #include "java/sql/Connection.hxx"
30cdf0e10cSrcweir #include "java/sql/SQLWarning.hxx"
31cdf0e10cSrcweir #include "java/tools.hxx"
32cdf0e10cSrcweir #include "java/ContextClassLoader.hxx"
33cdf0e10cSrcweir #include <comphelper/property.hxx>
34cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
35cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
36cdf0e10cSrcweir #include <comphelper/sequence.hxx>
37cdf0e10cSrcweir #include "TConnection.hxx"
38cdf0e10cSrcweir #include <comphelper/types.hxx>
39cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
40cdf0e10cSrcweir #include <com/sun/star/sdbc/ResultSetType.hpp>
41cdf0e10cSrcweir #include <com/sun/star/sdbc/FetchDirection.hpp>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "resource/jdbc_log.hrc"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <algorithm>
46cdf0e10cSrcweir #include <string.h>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir using namespace ::comphelper;
49cdf0e10cSrcweir using namespace connectivity;
50cdf0e10cSrcweir using namespace ::cppu;
51cdf0e10cSrcweir //------------------------------------------------------------------------------
52cdf0e10cSrcweir using namespace ::com::sun::star::uno;
53cdf0e10cSrcweir using namespace ::com::sun::star::beans;
54cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
55cdf0e10cSrcweir using namespace ::com::sun::star::container;
56cdf0e10cSrcweir using namespace ::com::sun::star::lang;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir //------------------------------------------------------------------------------
59cdf0e10cSrcweir //**************************************************************
60cdf0e10cSrcweir //************ Class: java.sql.Statement
61cdf0e10cSrcweir //**************************************************************
62cdf0e10cSrcweir 
63cdf0e10cSrcweir jclass java_sql_Statement_Base::theClass = 0;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir // -------------------------------------------------------------------------
java_sql_Statement_Base(JNIEnv * pEnv,java_sql_Connection & _rCon)66cdf0e10cSrcweir java_sql_Statement_Base::java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connection& _rCon )
67cdf0e10cSrcweir 	:java_sql_Statement_BASE(m_aMutex)
68cdf0e10cSrcweir 	,java_lang_Object( pEnv, NULL )
69cdf0e10cSrcweir 	,OPropertySetHelper(java_sql_Statement_BASE::rBHelper)
70cdf0e10cSrcweir 	,m_pConnection( &_rCon )
71cdf0e10cSrcweir     ,m_aLogger( _rCon.getLogger(), java::sql::ConnectionLog::STATEMENT )
72cdf0e10cSrcweir 	,m_nResultSetConcurrency(ResultSetConcurrency::READ_ONLY)
73cdf0e10cSrcweir 	,m_nResultSetType(ResultSetType::FORWARD_ONLY)
74cdf0e10cSrcweir     ,m_bEscapeProcessing(sal_True)
75cdf0e10cSrcweir     ,rBHelper(java_sql_Statement_BASE::rBHelper)
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	m_pConnection->acquire();
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir //------------------------------------------------------------------------------
~java_sql_Statement_Base()81cdf0e10cSrcweir java_sql_Statement_Base::~java_sql_Statement_Base()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir //------------------------------------------------------------------------------
disposing()86cdf0e10cSrcweir void SAL_CALL OStatement_BASE2::disposing()
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	if ( object )
91cdf0e10cSrcweir 	{
92cdf0e10cSrcweir         static jmethodID mID(NULL);
93cdf0e10cSrcweir         callVoidMethod("close",mID);
94cdf0e10cSrcweir 	}
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	::comphelper::disposeComponent(m_xGeneratedStatement);
97cdf0e10cSrcweir 	if (m_pConnection)
98cdf0e10cSrcweir 		m_pConnection->release();
99cdf0e10cSrcweir 	m_pConnection = NULL;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	dispose_ChildImpl();
102cdf0e10cSrcweir 	java_sql_Statement_Base::disposing();
103cdf0e10cSrcweir }
104cdf0e10cSrcweir // -------------------------------------------------------------------------
getMyClass() const105cdf0e10cSrcweir jclass java_sql_Statement_Base::getMyClass() const
106cdf0e10cSrcweir {
107cdf0e10cSrcweir 	// die Klasse muss nur einmal geholt werden, daher statisch
108cdf0e10cSrcweir 	if( !theClass )
109cdf0e10cSrcweir         theClass = findMyClass("java/sql/Statement");
110cdf0e10cSrcweir 	return theClass;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir // -----------------------------------------------------------------------------
disposing(void)113cdf0e10cSrcweir void SAL_CALL java_sql_Statement_Base::disposing(void)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINE, STR_LOG_CLOSING_STATEMENT );
116cdf0e10cSrcweir 	java_sql_Statement_BASE::disposing();
117cdf0e10cSrcweir 	clearObject();
118cdf0e10cSrcweir }
119cdf0e10cSrcweir // -------------------------------------------------------------------------
120cdf0e10cSrcweir 
release()121cdf0e10cSrcweir void SAL_CALL OStatement_BASE2::release() throw()
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	relase_ChildImpl();
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir // -------------------------------------------------------------------------
queryInterface(const Type & rType)127cdf0e10cSrcweir Any SAL_CALL java_sql_Statement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() && rType == ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ) )
130cdf0e10cSrcweir 		return Any();
131cdf0e10cSrcweir 	Any aRet( java_sql_Statement_BASE::queryInterface(rType) );
132cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
133cdf0e10cSrcweir }
134cdf0e10cSrcweir // -------------------------------------------------------------------------
getTypes()135cdf0e10cSrcweir Sequence< Type > SAL_CALL java_sql_Statement_Base::getTypes(  ) throw(RuntimeException)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	::cppu::OTypeCollection aTypes(	::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
138cdf0e10cSrcweir 												::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
139cdf0e10cSrcweir 												::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes();
142cdf0e10cSrcweir 	if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() )
143cdf0e10cSrcweir 	{
144cdf0e10cSrcweir 		::std::remove(aOldTypes.getArray(),aOldTypes.getArray() + aOldTypes.getLength(),
145cdf0e10cSrcweir 						::getCppuType( (const Reference< XGeneratedResultSet > *)0 ));
146cdf0e10cSrcweir 		aOldTypes.realloc(aOldTypes.getLength() - 1);
147cdf0e10cSrcweir 	}
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 	return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes);
150cdf0e10cSrcweir }
151cdf0e10cSrcweir // -----------------------------------------------------------------------------
getGeneratedValues()152cdf0e10cSrcweir Reference< XResultSet > SAL_CALL java_sql_Statement_Base::getGeneratedValues(  ) throw (SQLException, RuntimeException)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINE, STR_LOG_GENERATED_VALUES );
155cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
156cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	jobject out(0);
159cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
160cdf0e10cSrcweir 	createStatement(t.pEnv);
161cdf0e10cSrcweir 	// temporaere Variable initialisieren
162cdf0e10cSrcweir 	try
163cdf0e10cSrcweir     {
164cdf0e10cSrcweir         static jmethodID mID(NULL);
165cdf0e10cSrcweir         out = callResultSetMethod(t.env(),"getGeneratedKeys",mID);
166cdf0e10cSrcweir     }
167cdf0e10cSrcweir     catch(const SQLException&)
168cdf0e10cSrcweir     {
169cdf0e10cSrcweir         // ignore
170cdf0e10cSrcweir     }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	Reference< XResultSet > xRes;
173cdf0e10cSrcweir 	if ( !out )
174cdf0e10cSrcweir 	{
175cdf0e10cSrcweir 		OSL_ENSURE(	m_pConnection && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
176cdf0e10cSrcweir 		if ( m_pConnection )
177cdf0e10cSrcweir 		{
178cdf0e10cSrcweir 			::rtl::OUString sStmt = m_pConnection->getTransformedGeneratedStatement(m_sSqlStatement);
179cdf0e10cSrcweir 			if ( sStmt.getLength() )
180cdf0e10cSrcweir 			{
181cdf0e10cSrcweir                 m_aLogger.log( LogLevel::FINER, STR_LOG_GENERATED_VALUES_FALLBACK, sStmt );
182cdf0e10cSrcweir 				::comphelper::disposeComponent(m_xGeneratedStatement);
183cdf0e10cSrcweir 				m_xGeneratedStatement = m_pConnection->createStatement();
184cdf0e10cSrcweir 				xRes = m_xGeneratedStatement->executeQuery(sStmt);
185cdf0e10cSrcweir 			}
186cdf0e10cSrcweir 		}
187cdf0e10cSrcweir 	}
188cdf0e10cSrcweir 	else
189cdf0e10cSrcweir 		xRes = new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection, this );
190cdf0e10cSrcweir 	return xRes;
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir // -------------------------------------------------------------------------
194cdf0e10cSrcweir 
cancel()195cdf0e10cSrcweir void SAL_CALL java_sql_Statement_Base::cancel(  ) throw(RuntimeException)
196cdf0e10cSrcweir {
197cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
198cdf0e10cSrcweir 	createStatement(t.pEnv);
199cdf0e10cSrcweir     static jmethodID mID(NULL);
200cdf0e10cSrcweir     callVoidMethod("cancel",mID);
201cdf0e10cSrcweir }
202cdf0e10cSrcweir // -------------------------------------------------------------------------
203cdf0e10cSrcweir 
close()204cdf0e10cSrcweir void SAL_CALL java_sql_Statement_Base::close(  ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
205cdf0e10cSrcweir {
206cdf0e10cSrcweir 	{
207cdf0e10cSrcweir 		::osl::MutexGuard aGuard( m_aMutex );
208cdf0e10cSrcweir 		if (java_sql_Statement_BASE::rBHelper.bDisposed)
209cdf0e10cSrcweir 			throw DisposedException();
210cdf0e10cSrcweir 	}
211cdf0e10cSrcweir 	dispose();
212cdf0e10cSrcweir }
213cdf0e10cSrcweir // -------------------------------------------------------------------------
214cdf0e10cSrcweir 
clearBatch()215cdf0e10cSrcweir void SAL_CALL java_sql_Statement::clearBatch(  ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
218cdf0e10cSrcweir 	{
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 		createStatement(t.pEnv);
221cdf0e10cSrcweir         static jmethodID mID(NULL);
222cdf0e10cSrcweir         callVoidMethod("clearBatch",mID);
223cdf0e10cSrcweir 	} //t.pEnv
224cdf0e10cSrcweir }
225cdf0e10cSrcweir // -------------------------------------------------------------------------
226cdf0e10cSrcweir 
execute(const::rtl::OUString & sql)227cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_Statement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
228cdf0e10cSrcweir {
229cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_STATEMENT, sql );
230cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
231cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 	jboolean out(sal_False);
234cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
235cdf0e10cSrcweir 	{
236cdf0e10cSrcweir 		createStatement(t.pEnv);
237cdf0e10cSrcweir 		m_sSqlStatement = sql;
238cdf0e10cSrcweir 		// temporaere Variable initialisieren
239cdf0e10cSrcweir 		static const char * cSignature = "(Ljava/lang/String;)Z";
240cdf0e10cSrcweir 		static const char * cMethodName = "execute";
241cdf0e10cSrcweir 		// Java-Call absetzen
242cdf0e10cSrcweir 		static jmethodID mID(NULL);
243cdf0e10cSrcweir         obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
244cdf0e10cSrcweir 		// Parameter konvertieren
245cdf0e10cSrcweir         jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
246cdf0e10cSrcweir         {
247cdf0e10cSrcweir             jdbc::ContextClassLoaderScope ccl( t.env(),
248cdf0e10cSrcweir                 m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
249cdf0e10cSrcweir                 m_aLogger,
250cdf0e10cSrcweir                 *this
251cdf0e10cSrcweir             );
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 		    out = t.pEnv->CallBooleanMethod( object, mID, str.get() );
254cdf0e10cSrcweir 		    ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
255cdf0e10cSrcweir         }
256cdf0e10cSrcweir 	} //t.pEnv
257cdf0e10cSrcweir 	return out;
258cdf0e10cSrcweir }
259cdf0e10cSrcweir // -------------------------------------------------------------------------
260cdf0e10cSrcweir 
executeQuery(const::rtl::OUString & sql)261cdf0e10cSrcweir Reference< XResultSet > SAL_CALL java_sql_Statement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
262cdf0e10cSrcweir {
263cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
264cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
265cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_QUERY, sql );
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     jobject out(0);
268cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	{
271cdf0e10cSrcweir 		createStatement(t.pEnv);
272cdf0e10cSrcweir 		m_sSqlStatement = sql;
273cdf0e10cSrcweir 		// temporaere Variable initialisieren
274cdf0e10cSrcweir 		static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/ResultSet;";
275cdf0e10cSrcweir 		static const char * cMethodName = "executeQuery";
276cdf0e10cSrcweir 		// Java-Call absetzen
277cdf0e10cSrcweir 		static jmethodID mID(NULL);
278cdf0e10cSrcweir         obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
279cdf0e10cSrcweir 		// Parameter konvertieren
280cdf0e10cSrcweir         jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
281cdf0e10cSrcweir         {
282cdf0e10cSrcweir             jdbc::ContextClassLoaderScope ccl( t.env(),
283cdf0e10cSrcweir                 m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
284cdf0e10cSrcweir                 m_aLogger,
285cdf0e10cSrcweir                 *this
286cdf0e10cSrcweir             );
287cdf0e10cSrcweir 
288cdf0e10cSrcweir 			out = t.pEnv->CallObjectMethod( object, mID, str.get() );
289cdf0e10cSrcweir     		ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
290cdf0e10cSrcweir         }
291cdf0e10cSrcweir 	} //t.pEnv
292cdf0e10cSrcweir 	// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
293cdf0e10cSrcweir     return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this );
294cdf0e10cSrcweir }
295cdf0e10cSrcweir // -------------------------------------------------------------------------
getConnection()296cdf0e10cSrcweir Reference< XConnection > SAL_CALL java_sql_Statement_Base::getConnection(  ) throw(SQLException, RuntimeException)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
299cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
300cdf0e10cSrcweir 	return (Reference< XConnection >)m_pConnection;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir // -------------------------------------------------------------------------
303cdf0e10cSrcweir 
queryInterface(const Type & rType)304cdf0e10cSrcweir Any SAL_CALL java_sql_Statement::queryInterface( const Type & rType ) throw(RuntimeException)
305cdf0e10cSrcweir {
306cdf0e10cSrcweir 	Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
307cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : java_sql_Statement_Base::queryInterface(rType);
308cdf0e10cSrcweir }
309cdf0e10cSrcweir // -------------------------------------------------------------------------
310cdf0e10cSrcweir 
addBatch(const::rtl::OUString & sql)311cdf0e10cSrcweir void SAL_CALL java_sql_Statement::addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
312cdf0e10cSrcweir {
313cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
314cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
315cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
316cdf0e10cSrcweir 	{
317cdf0e10cSrcweir 		createStatement(t.pEnv);
318cdf0e10cSrcweir         static jmethodID mID(NULL);
319cdf0e10cSrcweir         callVoidMethodWithStringArg("addBatch",mID,sql);
320cdf0e10cSrcweir 	} //t.pEnv
321cdf0e10cSrcweir }
322cdf0e10cSrcweir // -------------------------------------------------------------------------
323cdf0e10cSrcweir 
executeBatch()324cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL java_sql_Statement::executeBatch(  ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
327cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
328cdf0e10cSrcweir 	Sequence< sal_Int32 > aSeq;
329cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
330cdf0e10cSrcweir     createStatement(t.pEnv);
331cdf0e10cSrcweir     static jmethodID mID(NULL);
332cdf0e10cSrcweir     jintArray out = (jintArray)callObjectMethod(t.pEnv,"executeBatch","()[I", mID);
333cdf0e10cSrcweir 	if (out)
334cdf0e10cSrcweir 	{
335cdf0e10cSrcweir 		jboolean p = sal_False;
336cdf0e10cSrcweir 		aSeq.realloc(t.pEnv->GetArrayLength(out));
337cdf0e10cSrcweir 		memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength());
338cdf0e10cSrcweir 		t.pEnv->DeleteLocalRef(out);
339cdf0e10cSrcweir 	}
340cdf0e10cSrcweir 	return aSeq;
341cdf0e10cSrcweir }
342cdf0e10cSrcweir // -------------------------------------------------------------------------
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 
executeUpdate(const::rtl::OUString & sql)345cdf0e10cSrcweir sal_Int32 SAL_CALL java_sql_Statement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
348cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
349cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_UPDATE, sql );
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
352cdf0e10cSrcweir 	createStatement(t.pEnv);
353cdf0e10cSrcweir 	m_sSqlStatement = sql;
354cdf0e10cSrcweir     static jmethodID mID(NULL);
355cdf0e10cSrcweir     return callIntMethodWithStringArg("executeUpdate",mID,sql);
356cdf0e10cSrcweir }
357cdf0e10cSrcweir // -------------------------------------------------------------------------
358cdf0e10cSrcweir 
getResultSet()359cdf0e10cSrcweir Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Statement_Base::getResultSet(  ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
362cdf0e10cSrcweir 	createStatement(t.pEnv);
363cdf0e10cSrcweir     static jmethodID mID(NULL);
364cdf0e10cSrcweir     jobject out = callResultSetMethod(t.env(),"getResultSet",mID);
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 	// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
367cdf0e10cSrcweir 	return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this );
368cdf0e10cSrcweir }
369cdf0e10cSrcweir // -------------------------------------------------------------------------
370cdf0e10cSrcweir 
getUpdateCount()371cdf0e10cSrcweir sal_Int32 SAL_CALL java_sql_Statement_Base::getUpdateCount(  ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
372cdf0e10cSrcweir {
373cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
374cdf0e10cSrcweir 	createStatement(t.pEnv);
375cdf0e10cSrcweir     static jmethodID mID(NULL);
376cdf0e10cSrcweir 	sal_Int32 out = callIntMethod("getUpdateCount",mID);
377cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINER, STR_LOG_UPDATE_COUNT, (sal_Int32)out );
378cdf0e10cSrcweir 	return out;
379cdf0e10cSrcweir }
380cdf0e10cSrcweir // -------------------------------------------------------------------------
381cdf0e10cSrcweir 
getMoreResults()382cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_Statement_Base::getMoreResults(  ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
383cdf0e10cSrcweir {
384cdf0e10cSrcweir     static jmethodID mID(NULL);
385cdf0e10cSrcweir     return callBooleanMethod( "getMoreResults", mID );
386cdf0e10cSrcweir }
387cdf0e10cSrcweir // -------------------------------------------------------------------------
388cdf0e10cSrcweir 
389cdf0e10cSrcweir // -------------------------------------------------------------------------
getWarnings()390cdf0e10cSrcweir Any SAL_CALL java_sql_Statement_Base::getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
391cdf0e10cSrcweir {
392cdf0e10cSrcweir 	SDBThreadAttach t;
393cdf0e10cSrcweir     createStatement(t.pEnv);
394cdf0e10cSrcweir     static jmethodID mID(NULL);
395cdf0e10cSrcweir     jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID);
396cdf0e10cSrcweir 	// ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
397cdf0e10cSrcweir 	if( out )
398cdf0e10cSrcweir 	{
399cdf0e10cSrcweir 		java_sql_SQLWarning_BASE		warn_base( t.pEnv, out );
400cdf0e10cSrcweir 		return makeAny(
401cdf0e10cSrcweir             static_cast< starsdbc::SQLException >(
402cdf0e10cSrcweir                 java_sql_SQLWarning(warn_base,*(::cppu::OWeakObject*)this)));
403cdf0e10cSrcweir 	}
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 	return Any();
406cdf0e10cSrcweir }
407cdf0e10cSrcweir // -------------------------------------------------------------------------
clearWarnings()408cdf0e10cSrcweir void SAL_CALL java_sql_Statement_Base::clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
409cdf0e10cSrcweir {
410cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
411cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
412cdf0e10cSrcweir 	SDBThreadAttach t;
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 	{
415cdf0e10cSrcweir 		createStatement(t.pEnv);
416cdf0e10cSrcweir         static jmethodID mID(NULL);
417cdf0e10cSrcweir         callVoidMethod("clearWarnings",mID);
418cdf0e10cSrcweir 	}
419cdf0e10cSrcweir }
420cdf0e10cSrcweir //------------------------------------------------------------------------------
getQueryTimeOut()421cdf0e10cSrcweir sal_Int32 java_sql_Statement_Base::getQueryTimeOut()  throw(SQLException, RuntimeException)
422cdf0e10cSrcweir {
423cdf0e10cSrcweir     static jmethodID mID(NULL);
424cdf0e10cSrcweir     return impl_getProperty("getQueryTimeOut",mID);
425cdf0e10cSrcweir }
426cdf0e10cSrcweir //------------------------------------------------------------------------------
getMaxRows()427cdf0e10cSrcweir sal_Int32 java_sql_Statement_Base::getMaxRows() throw(SQLException, RuntimeException)
428cdf0e10cSrcweir {
429cdf0e10cSrcweir     static jmethodID mID(NULL);
430cdf0e10cSrcweir     return impl_getProperty("getMaxRows",mID);
431cdf0e10cSrcweir }
432cdf0e10cSrcweir //------------------------------------------------------------------------------
getResultSetConcurrency()433cdf0e10cSrcweir sal_Int32 java_sql_Statement_Base::getResultSetConcurrency() throw(SQLException, RuntimeException)
434cdf0e10cSrcweir {
435cdf0e10cSrcweir     static jmethodID mID(NULL);
436cdf0e10cSrcweir     return impl_getProperty("getResultSetConcurrency",mID,m_nResultSetConcurrency);
437cdf0e10cSrcweir }
438cdf0e10cSrcweir 
439cdf0e10cSrcweir //------------------------------------------------------------------------------
getResultSetType()440cdf0e10cSrcweir sal_Int32 java_sql_Statement_Base::getResultSetType() throw(SQLException, RuntimeException)
441cdf0e10cSrcweir {
442cdf0e10cSrcweir     static jmethodID mID(NULL);
443cdf0e10cSrcweir     return impl_getProperty("getResultSetType",mID,m_nResultSetType);
444cdf0e10cSrcweir }
445cdf0e10cSrcweir //------------------------------------------------------------------------------
impl_getProperty(const char * _pMethodName,jmethodID & _inout_MethodID,sal_Int32 _nDefault)446cdf0e10cSrcweir sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault)
447cdf0e10cSrcweir {
448cdf0e10cSrcweir     sal_Int32 out = _nDefault;
449cdf0e10cSrcweir     if ( object )
450cdf0e10cSrcweir         out = callIntMethod(_pMethodName,_inout_MethodID,true);
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 	return out;
453cdf0e10cSrcweir }
454cdf0e10cSrcweir //------------------------------------------------------------------------------
impl_getProperty(const char * _pMethodName,jmethodID & _inout_MethodID)455cdf0e10cSrcweir sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID)
456cdf0e10cSrcweir {
457cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
458cdf0e10cSrcweir 	createStatement(t.pEnv);
459cdf0e10cSrcweir     return callIntMethod(_pMethodName,_inout_MethodID,true);
460cdf0e10cSrcweir }
461cdf0e10cSrcweir 
462cdf0e10cSrcweir //------------------------------------------------------------------------------
getFetchDirection()463cdf0e10cSrcweir sal_Int32 java_sql_Statement_Base::getFetchDirection() throw(SQLException, RuntimeException)
464cdf0e10cSrcweir {
465cdf0e10cSrcweir     static jmethodID mID(NULL);
466cdf0e10cSrcweir     return impl_getProperty("getFetchDirection",mID);
467cdf0e10cSrcweir }
468cdf0e10cSrcweir //------------------------------------------------------------------------------
getFetchSize()469cdf0e10cSrcweir sal_Int32 java_sql_Statement_Base::getFetchSize() throw(SQLException, RuntimeException)
470cdf0e10cSrcweir {
471cdf0e10cSrcweir     static jmethodID mID(NULL);
472cdf0e10cSrcweir     return impl_getProperty("getFetchSize",mID);
473cdf0e10cSrcweir }
474cdf0e10cSrcweir //------------------------------------------------------------------------------
getMaxFieldSize()475cdf0e10cSrcweir sal_Int32 java_sql_Statement_Base::getMaxFieldSize() throw(SQLException, RuntimeException)
476cdf0e10cSrcweir {
477cdf0e10cSrcweir     static jmethodID mID(NULL);
478cdf0e10cSrcweir     return impl_getProperty("getMaxFieldSize",mID);
479cdf0e10cSrcweir }
480cdf0e10cSrcweir //------------------------------------------------------------------------------
getCursorName()481cdf0e10cSrcweir ::rtl::OUString java_sql_Statement_Base::getCursorName() throw(SQLException, RuntimeException)
482cdf0e10cSrcweir {
483cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
484cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
485cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
486cdf0e10cSrcweir     createStatement(t.pEnv);
487cdf0e10cSrcweir     static jmethodID mID(NULL);
488cdf0e10cSrcweir     try
489cdf0e10cSrcweir     {
490cdf0e10cSrcweir         return callStringMethod("getCursorName",mID);
491cdf0e10cSrcweir     }
492cdf0e10cSrcweir     catch(const SQLException&)
493cdf0e10cSrcweir     {
494cdf0e10cSrcweir     }
495cdf0e10cSrcweir     return ::rtl::OUString();
496cdf0e10cSrcweir }
497cdf0e10cSrcweir //------------------------------------------------------------------------------
setQueryTimeOut(sal_Int32 _par0)498cdf0e10cSrcweir void java_sql_Statement_Base::setQueryTimeOut(sal_Int32 _par0) throw(SQLException, RuntimeException)
499cdf0e10cSrcweir {
500cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
501cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
502cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
503cdf0e10cSrcweir     createStatement(t.pEnv);
504cdf0e10cSrcweir     static jmethodID mID(NULL);
505cdf0e10cSrcweir     callVoidMethodWithIntArg("setQueryTimeOut",mID,_par0,true);
506cdf0e10cSrcweir }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir //------------------------------------------------------------------------------
setEscapeProcessing(sal_Bool _par0)509cdf0e10cSrcweir void java_sql_Statement_Base::setEscapeProcessing(sal_Bool _par0) throw(SQLException, RuntimeException)
510cdf0e10cSrcweir {
511cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
512cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
513cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINE, STR_LOG_SET_ESCAPE_PROCESSING, _par0 );
514cdf0e10cSrcweir 
515cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
516cdf0e10cSrcweir     m_bEscapeProcessing = _par0;
517cdf0e10cSrcweir     createStatement( t.pEnv );
518cdf0e10cSrcweir     static jmethodID mID(NULL);
519cdf0e10cSrcweir     callVoidMethodWithBoolArg("setEscapeProcessing",mID,_par0,true);
520cdf0e10cSrcweir }
521cdf0e10cSrcweir 
522cdf0e10cSrcweir //------------------------------------------------------------------------------
setMaxRows(sal_Int32 _par0)523cdf0e10cSrcweir void java_sql_Statement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, RuntimeException)
524cdf0e10cSrcweir {
525cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
526cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
527cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
528cdf0e10cSrcweir     createStatement(t.pEnv);
529cdf0e10cSrcweir     static jmethodID mID(NULL);
530cdf0e10cSrcweir     callVoidMethodWithIntArg("setMaxRows",mID,_par0,true);
531cdf0e10cSrcweir }
532cdf0e10cSrcweir //------------------------------------------------------------------------------
setResultSetConcurrency(sal_Int32 _par0)533cdf0e10cSrcweir void java_sql_Statement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException)
534cdf0e10cSrcweir {
535cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
536cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
537cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINE, STR_LOG_RESULT_SET_CONCURRENCY, (sal_Int32)_par0 );
538cdf0e10cSrcweir 	m_nResultSetConcurrency = _par0;
539cdf0e10cSrcweir 
540cdf0e10cSrcweir     clearObject();
541cdf0e10cSrcweir }
542cdf0e10cSrcweir //------------------------------------------------------------------------------
setResultSetType(sal_Int32 _par0)543cdf0e10cSrcweir void java_sql_Statement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException)
544cdf0e10cSrcweir {
545cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
546cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
547cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINE, STR_LOG_RESULT_SET_TYPE, (sal_Int32)_par0 );
548cdf0e10cSrcweir 	m_nResultSetType = _par0;
549cdf0e10cSrcweir 
550cdf0e10cSrcweir     clearObject();
551cdf0e10cSrcweir }
552cdf0e10cSrcweir //------------------------------------------------------------------------------
setFetchDirection(sal_Int32 _par0)553cdf0e10cSrcweir void java_sql_Statement_Base::setFetchDirection(sal_Int32 _par0) throw(SQLException, RuntimeException)
554cdf0e10cSrcweir {
555cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
556cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
557cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINER, STR_LOG_FETCH_DIRECTION, (sal_Int32)_par0 );
558cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
559cdf0e10cSrcweir     createStatement(t.pEnv);
560cdf0e10cSrcweir     static jmethodID mID(NULL);
561cdf0e10cSrcweir     callVoidMethodWithIntArg("setFetchDirection",mID,_par0,true);
562cdf0e10cSrcweir }
563cdf0e10cSrcweir //------------------------------------------------------------------------------
setFetchSize(sal_Int32 _par0)564cdf0e10cSrcweir void java_sql_Statement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException)
565cdf0e10cSrcweir {
566cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
567cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
568cdf0e10cSrcweir     m_aLogger.log( LogLevel::FINER, STR_LOG_FETCH_SIZE, (sal_Int32)_par0 );
569cdf0e10cSrcweir 
570cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
571cdf0e10cSrcweir     createStatement(t.pEnv);
572cdf0e10cSrcweir     static jmethodID mID(NULL);
573cdf0e10cSrcweir     callVoidMethodWithIntArg("setFetchSize",mID,_par0,true);
574cdf0e10cSrcweir }
575cdf0e10cSrcweir //------------------------------------------------------------------------------
setMaxFieldSize(sal_Int32 _par0)576cdf0e10cSrcweir void java_sql_Statement_Base::setMaxFieldSize(sal_Int32 _par0) throw(SQLException, RuntimeException)
577cdf0e10cSrcweir {
578cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
579cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
580cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
581cdf0e10cSrcweir     createStatement(t.pEnv);
582cdf0e10cSrcweir     static jmethodID mID(NULL);
583cdf0e10cSrcweir     callVoidMethodWithIntArg("setMaxFieldSize",mID,_par0,true);
584cdf0e10cSrcweir }
585cdf0e10cSrcweir //------------------------------------------------------------------------------
setCursorName(const::rtl::OUString & _par0)586cdf0e10cSrcweir void java_sql_Statement_Base::setCursorName(const ::rtl::OUString &_par0) throw(SQLException, RuntimeException)
587cdf0e10cSrcweir {
588cdf0e10cSrcweir     ::osl::MutexGuard aGuard( m_aMutex );
589cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
590cdf0e10cSrcweir     SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
591cdf0e10cSrcweir 	{
592cdf0e10cSrcweir 		createStatement(t.pEnv);
593cdf0e10cSrcweir         static jmethodID mID(NULL);
594cdf0e10cSrcweir         callVoidMethodWithStringArg("setCursorName",mID,_par0);
595cdf0e10cSrcweir 	} //t.pEnv
596cdf0e10cSrcweir }
597cdf0e10cSrcweir 
598cdf0e10cSrcweir // -------------------------------------------------------------------------
createArrayHelper() const599cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* java_sql_Statement_Base::createArrayHelper( ) const
600cdf0e10cSrcweir {
601cdf0e10cSrcweir 	Sequence< Property > aProps(10);
602cdf0e10cSrcweir 	Property* pProperties = aProps.getArray();
603cdf0e10cSrcweir 	sal_Int32 nPos = 0;
604cdf0e10cSrcweir 	DECL_PROP0(CURSORNAME,	::rtl::OUString);
605cdf0e10cSrcweir 	DECL_BOOL_PROP0(ESCAPEPROCESSING);
606cdf0e10cSrcweir 	DECL_PROP0(FETCHDIRECTION,sal_Int32);
607cdf0e10cSrcweir 	DECL_PROP0(FETCHSIZE,	sal_Int32);
608cdf0e10cSrcweir 	DECL_PROP0(MAXFIELDSIZE,sal_Int32);
609cdf0e10cSrcweir 	DECL_PROP0(MAXROWS,		sal_Int32);
610cdf0e10cSrcweir 	DECL_PROP0(QUERYTIMEOUT,sal_Int32);
611cdf0e10cSrcweir 	DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
612cdf0e10cSrcweir 	DECL_PROP0(RESULTSETTYPE,sal_Int32);
613cdf0e10cSrcweir 	DECL_BOOL_PROP0(USEBOOKMARKS);
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 	return new ::cppu::OPropertyArrayHelper(aProps);
616cdf0e10cSrcweir }
617cdf0e10cSrcweir 
618cdf0e10cSrcweir // -------------------------------------------------------------------------
getInfoHelper()619cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & java_sql_Statement_Base::getInfoHelper()
620cdf0e10cSrcweir 
621cdf0e10cSrcweir {
622cdf0e10cSrcweir 	return *const_cast<java_sql_Statement_Base*>(this)->getArrayHelper();
623cdf0e10cSrcweir }
624cdf0e10cSrcweir // -------------------------------------------------------------------------
convertFastPropertyValue(Any & rConvertedValue,Any & rOldValue,sal_Int32 nHandle,const Any & rValue)625cdf0e10cSrcweir sal_Bool java_sql_Statement_Base::convertFastPropertyValue(
626cdf0e10cSrcweir 							Any & rConvertedValue,
627cdf0e10cSrcweir 							Any & rOldValue,
628cdf0e10cSrcweir 							sal_Int32 nHandle,
629cdf0e10cSrcweir 							const Any& rValue )
630cdf0e10cSrcweir 								throw (::com::sun::star::lang::IllegalArgumentException)
631cdf0e10cSrcweir {
632cdf0e10cSrcweir 	switch(nHandle)
633cdf0e10cSrcweir 	{
634cdf0e10cSrcweir 		case PROPERTY_ID_QUERYTIMEOUT:
635cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
636cdf0e10cSrcweir 		case PROPERTY_ID_MAXFIELDSIZE:
637cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize());
638cdf0e10cSrcweir 		case PROPERTY_ID_MAXROWS:
639cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxRows());
640cdf0e10cSrcweir 		case PROPERTY_ID_CURSORNAME:
641cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName());
642cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETCONCURRENCY:
643cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency());
644cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETTYPE:
645cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType());
646cdf0e10cSrcweir 		case PROPERTY_ID_FETCHDIRECTION:
647cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
648cdf0e10cSrcweir 		case PROPERTY_ID_FETCHSIZE:
649cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
650cdf0e10cSrcweir 		case PROPERTY_ID_ESCAPEPROCESSING:
651cdf0e10cSrcweir 			return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEscapeProcessing );
652cdf0e10cSrcweir 		case PROPERTY_ID_USEBOOKMARKS:
653cdf0e10cSrcweir 			//	return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
654cdf0e10cSrcweir 		default:
655cdf0e10cSrcweir 			;
656cdf0e10cSrcweir 	}
657cdf0e10cSrcweir 	return sal_False;
658cdf0e10cSrcweir }
659cdf0e10cSrcweir // -------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any & rValue)660cdf0e10cSrcweir void java_sql_Statement_Base::setFastPropertyValue_NoBroadcast(
661cdf0e10cSrcweir 								sal_Int32 nHandle,
662cdf0e10cSrcweir 								const Any& rValue
663cdf0e10cSrcweir 												 )
664cdf0e10cSrcweir 												 throw (Exception)
665cdf0e10cSrcweir {
666cdf0e10cSrcweir 	switch(nHandle)
667cdf0e10cSrcweir 	{
668cdf0e10cSrcweir 		case PROPERTY_ID_QUERYTIMEOUT:
669cdf0e10cSrcweir 			setQueryTimeOut(comphelper::getINT32(rValue));
670cdf0e10cSrcweir 			break;
671cdf0e10cSrcweir 		case PROPERTY_ID_MAXFIELDSIZE:
672cdf0e10cSrcweir 			setMaxFieldSize(comphelper::getINT32(rValue));
673cdf0e10cSrcweir 			break;
674cdf0e10cSrcweir 		case PROPERTY_ID_MAXROWS:
675cdf0e10cSrcweir 			setMaxRows(comphelper::getINT32(rValue));
676cdf0e10cSrcweir 			break;
677cdf0e10cSrcweir 		case PROPERTY_ID_CURSORNAME:
678cdf0e10cSrcweir 			setCursorName(comphelper::getString(rValue));
679cdf0e10cSrcweir 			break;
680cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETCONCURRENCY:
681cdf0e10cSrcweir 			setResultSetConcurrency(comphelper::getINT32(rValue));
682cdf0e10cSrcweir 			break;
683cdf0e10cSrcweir 		case PROPERTY_ID_RESULTSETTYPE:
684cdf0e10cSrcweir 			setResultSetType(comphelper::getINT32(rValue));
685cdf0e10cSrcweir 			break;
686cdf0e10cSrcweir 		case PROPERTY_ID_FETCHDIRECTION:
687cdf0e10cSrcweir 			setFetchDirection(comphelper::getINT32(rValue));
688cdf0e10cSrcweir 			break;
689cdf0e10cSrcweir 		case PROPERTY_ID_FETCHSIZE:
690cdf0e10cSrcweir 			setFetchSize(comphelper::getINT32(rValue));
691cdf0e10cSrcweir 			break;
692cdf0e10cSrcweir 		case PROPERTY_ID_ESCAPEPROCESSING:
693cdf0e10cSrcweir             setEscapeProcessing( ::comphelper::getBOOL( rValue ) );
694cdf0e10cSrcweir             break;
695cdf0e10cSrcweir 		case PROPERTY_ID_USEBOOKMARKS:
696cdf0e10cSrcweir 			//	return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
697cdf0e10cSrcweir 		default:
698cdf0e10cSrcweir 			;
699cdf0e10cSrcweir 	}
700cdf0e10cSrcweir }
701cdf0e10cSrcweir // -------------------------------------------------------------------------
getFastPropertyValue(Any & rValue,sal_Int32 nHandle) const702cdf0e10cSrcweir void java_sql_Statement_Base::getFastPropertyValue(
703cdf0e10cSrcweir 								Any& rValue,
704cdf0e10cSrcweir 								sal_Int32 nHandle
705cdf0e10cSrcweir 									 ) const
706cdf0e10cSrcweir {
707cdf0e10cSrcweir 	java_sql_Statement_Base* THIS = const_cast<java_sql_Statement_Base*>(this);
708cdf0e10cSrcweir     try
709cdf0e10cSrcweir     {
710cdf0e10cSrcweir 	    switch(nHandle)
711cdf0e10cSrcweir 	    {
712cdf0e10cSrcweir 		    case PROPERTY_ID_QUERYTIMEOUT:
713cdf0e10cSrcweir 			    rValue <<= THIS->getQueryTimeOut();
714cdf0e10cSrcweir 			    break;
715cdf0e10cSrcweir 		    case PROPERTY_ID_MAXFIELDSIZE:
716cdf0e10cSrcweir 			    rValue <<= THIS->getMaxFieldSize();
717cdf0e10cSrcweir 			    break;
718cdf0e10cSrcweir 		    case PROPERTY_ID_MAXROWS:
719cdf0e10cSrcweir 			    rValue <<= THIS->getMaxRows();
720cdf0e10cSrcweir 			    break;
721cdf0e10cSrcweir 		    case PROPERTY_ID_CURSORNAME:
722cdf0e10cSrcweir 			    rValue <<= THIS->getCursorName();
723cdf0e10cSrcweir 			    break;
724cdf0e10cSrcweir 		    case PROPERTY_ID_RESULTSETCONCURRENCY:
725cdf0e10cSrcweir 			    rValue <<= THIS->getResultSetConcurrency();
726cdf0e10cSrcweir 			    break;
727cdf0e10cSrcweir 		    case PROPERTY_ID_RESULTSETTYPE:
728cdf0e10cSrcweir 			    rValue <<= THIS->getResultSetType();
729cdf0e10cSrcweir 			    break;
730cdf0e10cSrcweir 		    case PROPERTY_ID_FETCHDIRECTION:
731cdf0e10cSrcweir 			    rValue <<= THIS->getFetchDirection();
732cdf0e10cSrcweir 			    break;
733cdf0e10cSrcweir 		    case PROPERTY_ID_FETCHSIZE:
734cdf0e10cSrcweir 			    rValue <<= THIS->getFetchSize();
735cdf0e10cSrcweir 			    break;
736cdf0e10cSrcweir 		    case PROPERTY_ID_ESCAPEPROCESSING:
737cdf0e10cSrcweir                 rValue <<= (sal_Bool)m_bEscapeProcessing;
738cdf0e10cSrcweir                 break;
739cdf0e10cSrcweir 		    case PROPERTY_ID_USEBOOKMARKS:
740cdf0e10cSrcweir 		    default:
741cdf0e10cSrcweir 			    ;
742cdf0e10cSrcweir 	    }
743cdf0e10cSrcweir     }
744cdf0e10cSrcweir     catch(const Exception&)
745cdf0e10cSrcweir     {
746cdf0e10cSrcweir     }
747cdf0e10cSrcweir }
748cdf0e10cSrcweir // -------------------------------------------------------------------------
749cdf0e10cSrcweir jclass java_sql_Statement::theClass = 0;
750cdf0e10cSrcweir 
~java_sql_Statement()751cdf0e10cSrcweir java_sql_Statement::~java_sql_Statement()
752cdf0e10cSrcweir {}
753cdf0e10cSrcweir 
getMyClass() const754cdf0e10cSrcweir jclass java_sql_Statement::getMyClass() const
755cdf0e10cSrcweir {
756cdf0e10cSrcweir 	// die Klasse muss nur einmal geholt werden, daher statisch
757cdf0e10cSrcweir 	if( !theClass )
758cdf0e10cSrcweir         theClass = findMyClass("java/sql/Statement");
759cdf0e10cSrcweir 	return theClass;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir 
762cdf0e10cSrcweir // -----------------------------------------------------------------------------
createStatement(JNIEnv * _pEnv)763cdf0e10cSrcweir void java_sql_Statement::createStatement(JNIEnv* _pEnv)
764cdf0e10cSrcweir {
765cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
766cdf0e10cSrcweir 	checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
767cdf0e10cSrcweir 
768cdf0e10cSrcweir 	if( _pEnv && !object ){
769cdf0e10cSrcweir 		// temporaere Variable initialisieren
770cdf0e10cSrcweir 		static const char * cSignature = "(II)Ljava/sql/Statement;";
771cdf0e10cSrcweir 		static const char * cMethodName = "createStatement";
772cdf0e10cSrcweir 		// Java-Call absetzen
773cdf0e10cSrcweir 		jobject out = NULL;
774cdf0e10cSrcweir 		static jmethodID mID(NULL);
775cdf0e10cSrcweir 		if ( !mID  )
776cdf0e10cSrcweir 			mID  = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
777cdf0e10cSrcweir 		if( mID ){
778cdf0e10cSrcweir 			out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID,m_nResultSetType,m_nResultSetConcurrency );
779cdf0e10cSrcweir 		} //mID
780cdf0e10cSrcweir 		else
781cdf0e10cSrcweir 		{
782cdf0e10cSrcweir 			static const char * cSignature2 = "()Ljava/sql/Statement;";
783cdf0e10cSrcweir 			static jmethodID mID2 = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,"Unknown method id!");
784cdf0e10cSrcweir 			if( mID2 ){
785cdf0e10cSrcweir 				out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2);
786cdf0e10cSrcweir 			} //mID
787cdf0e10cSrcweir 		}
788cdf0e10cSrcweir 		ThrowLoggedSQLException( m_aLogger, _pEnv, *this );
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 		if ( out )
791cdf0e10cSrcweir 			object = _pEnv->NewGlobalRef( out );
792cdf0e10cSrcweir 	} //_pEnv
793cdf0e10cSrcweir }
794cdf0e10cSrcweir // -----------------------------------------------------------------------------
795cdf0e10cSrcweir 
796cdf0e10cSrcweir 
797cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(java_sql_Statement,"com.sun.star.sdbcx.JStatement","com.sun.star.sdbc.Statement");
798cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()799cdf0e10cSrcweir void SAL_CALL java_sql_Statement_Base::acquire() throw()
800cdf0e10cSrcweir {
801cdf0e10cSrcweir 	java_sql_Statement_BASE::acquire();
802cdf0e10cSrcweir }
803cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()804cdf0e10cSrcweir void SAL_CALL java_sql_Statement_Base::release() throw()
805cdf0e10cSrcweir {
806cdf0e10cSrcweir 	java_sql_Statement_BASE::release();
807cdf0e10cSrcweir }
808cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()809cdf0e10cSrcweir void SAL_CALL java_sql_Statement::acquire() throw()
810cdf0e10cSrcweir {
811cdf0e10cSrcweir 	OStatement_BASE2::acquire();
812cdf0e10cSrcweir }
813cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()814cdf0e10cSrcweir void SAL_CALL java_sql_Statement::release() throw()
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	OStatement_BASE2::release();
817cdf0e10cSrcweir }
818cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPropertySetInfo()819cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL java_sql_Statement_Base::getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException)
820cdf0e10cSrcweir {
821cdf0e10cSrcweir 	return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
822cdf0e10cSrcweir }
823cdf0e10cSrcweir // -----------------------------------------------------------------------------
824cdf0e10cSrcweir 
825cdf0e10cSrcweir 
826