LibreOffice Module connectivity (master) 1
JStatement.cxx
Go to the documentation of this file.
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
20
25#include <java/tools.hxx>
28#include <com/sun/star/lang/DisposedException.hpp>
32#include <TConnection.hxx>
33#include <comphelper/types.hxx>
35#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
36#include <com/sun/star/sdbc/ResultSetType.hpp>
37
38#include <strings.hxx>
39
40#include <algorithm>
41#include <string.h>
42
43using namespace ::comphelper;
44using namespace connectivity;
45using namespace ::cppu;
46
47using namespace ::com::sun::star::uno;
48using namespace ::com::sun::star::beans;
49using namespace ::com::sun::star::sdbc;
50using namespace ::com::sun::star::container;
51using namespace ::com::sun::star::lang;
52
53
54//************ Class: java.sql.Statement
55
56
57jclass java_sql_Statement_Base::theClass = nullptr;
58
59
60java_sql_Statement_Base::java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connection& _rCon )
62 ,java_lang_Object( pEnv, nullptr )
64 ,m_pConnection( &_rCon )
65 ,m_aLogger( _rCon.getLogger(), java::sql::ConnectionLog::STATEMENT )
66 ,m_nResultSetConcurrency(ResultSetConcurrency::READ_ONLY)
67 ,m_nResultSetType(ResultSetType::FORWARD_ONLY)
68 ,m_bEscapeProcessing(true)
69{
70}
71
72
74{
75}
76
77
79{
80 ::osl::MutexGuard aGuard(m_aMutex);
81
82 if ( object )
83 {
84 static jmethodID mID(nullptr);
85 callVoidMethod_ThrowSQL("close", mID);
86 }
87
88 ::comphelper::disposeComponent(m_xGeneratedStatement);
89 m_pConnection.clear();
90
92}
93
95{
96 // the class must be fetched only once, therefore static
97 if( !theClass )
98 theClass = findMyClass("java/sql/Statement");
99 return theClass;
100}
101
103{
104 m_aLogger.log( LogLevel::FINE, STR_LOG_CLOSING_STATEMENT );
105 java_sql_Statement_BASE::disposing();
106 clearObject();
107}
108
109
111{
112 if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() && rType == cppu::UnoType<XGeneratedResultSet>::get())
113 return Any();
114 Any aRet( java_sql_Statement_BASE::queryInterface(rType) );
115 return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
116}
117
118Sequence< Type > SAL_CALL java_sql_Statement_Base::getTypes( )
119{
123
124 Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes();
125 if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
126 {
127 auto [begin, end] = asNonConstRange(aOldTypes);
128 auto newEnd = std::remove(begin, end,
130 aOldTypes.realloc(std::distance(begin, newEnd));
131 }
132
133 return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes);
134}
135
136Reference< XResultSet > SAL_CALL java_sql_Statement_Base::getGeneratedValues( )
137{
138 m_aLogger.log( LogLevel::FINE, STR_LOG_GENERATED_VALUES );
139 ::osl::MutexGuard aGuard( m_aMutex );
140 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
141
142 jobject out(nullptr);
143 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
144 createStatement(t.pEnv);
145 // initialize temporary Variable
146 try
147 {
148 static jmethodID mID(nullptr);
149 out = callResultSetMethod(t.env(),"getGeneratedKeys",mID);
150 }
151 catch(const SQLException&)
152 {
153 // ignore
154 }
155
156 Reference< XResultSet > xRes;
157 if ( !out )
158 {
159 OSL_ENSURE( m_pConnection.is() && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
160 if ( m_pConnection.is() )
161 {
162 OUString sStmt = m_pConnection->getTransformedGeneratedStatement(m_sSqlStatement);
163 if ( !sStmt.isEmpty() )
164 {
165 m_aLogger.log( LogLevel::FINER, STR_LOG_GENERATED_VALUES_FALLBACK, sStmt );
166 ::comphelper::disposeComponent(m_xGeneratedStatement);
167 m_xGeneratedStatement = m_pConnection->createStatement();
168 xRes = m_xGeneratedStatement->executeQuery(sStmt);
169 }
170 }
171 }
172 else
173 xRes = new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection, this );
174 return xRes;
177
179{
180 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
181 createStatement(t.pEnv);
182 static jmethodID mID(nullptr);
183 callVoidMethod_ThrowRuntime("cancel",mID);
184}
185
186
188{
189 {
190 ::osl::MutexGuard aGuard( m_aMutex );
191 if (java_sql_Statement_BASE::rBHelper.bDisposed)
192 throw DisposedException();
193 }
194 dispose();
195}
196
197
199{
200 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
201 {
202
203 createStatement(t.pEnv);
204 static jmethodID mID(nullptr);
205 callVoidMethod_ThrowSQL("clearBatch", mID);
206 } //t.pEnv
207}
208
209
211{
212 m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_STATEMENT, sql );
213 ::osl::MutexGuard aGuard( m_aMutex );
214 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
215
216 bool out(false);
217 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
218 {
219 createStatement(t.pEnv);
221 // initialize temporary Variable
222 static const char * const cSignature = "(Ljava/lang/String;)Z";
223 static const char * const cMethodName = "execute";
224 // Java-Call
225 static jmethodID mID(nullptr);
226 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
227 // convert Parameter
229 {
231 m_pConnection.is() ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
232 m_aLogger,
233 *this
234 );
235
236 out = t.pEnv->CallBooleanMethod( object, mID, str.get() );
237 ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
238 }
239 } //t.pEnv
240 return out;
241}
242
243
244Reference< XResultSet > SAL_CALL java_sql_Statement_Base::executeQuery( const OUString& sql )
245{
246 ::osl::MutexGuard aGuard( m_aMutex );
247 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
248 m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_QUERY, sql );
249
250 jobject out(nullptr);
251 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
252
253 {
254 createStatement(t.pEnv);
256 // initialize temporary variable
257 static const char * const cSignature = "(Ljava/lang/String;)Ljava/sql/ResultSet;";
258 static const char * const cMethodName = "executeQuery";
259 // Java-Call
260 static jmethodID mID(nullptr);
261 obtainMethodId_throwSQL(t.pEnv, cMethodName,cSignature, mID);
262 // convert Parameter
264 {
266 m_pConnection.is() ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
267 m_aLogger,
268 *this
269 );
270
271 out = t.pEnv->CallObjectMethod( object, mID, str.get() );
272 ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
273 }
274 } //t.pEnv
275 // WARNING: the caller becomes the owner of the returned pointer
276 return out==nullptr ? nullptr : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this );
277}
278
279Reference< XConnection > SAL_CALL java_sql_Statement_Base::getConnection( )
280{
281 ::osl::MutexGuard aGuard( m_aMutex );
282 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
283 return m_pConnection;
284}
285
286
288{
289 Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
290 return aRet.hasValue() ? aRet : java_sql_Statement_Base::queryInterface(rType);
291}
292
293
294void SAL_CALL java_sql_Statement::addBatch( const OUString& sql )
295{
296 ::osl::MutexGuard aGuard( m_aMutex );
297 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
298 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
299 {
300 createStatement(t.pEnv);
301 static jmethodID mID(nullptr);
302 callVoidMethodWithStringArg("addBatch",mID,sql);
303 } //t.pEnv
304}
305
306
307Sequence< sal_Int32 > SAL_CALL java_sql_Statement::executeBatch( )
308{
309 ::osl::MutexGuard aGuard( m_aMutex );
310 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
311 Sequence< sal_Int32 > aSeq;
312 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
313 createStatement(t.pEnv);
314 static jmethodID mID(nullptr);
315 jintArray out = static_cast<jintArray>(callObjectMethod(t.pEnv,"executeBatch","()[I", mID));
316 if (out)
317 {
318 jboolean p = false;
319 aSeq.realloc(t.pEnv->GetArrayLength(out));
320 memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength());
321 t.pEnv->DeleteLocalRef(out);
322 }
323 return aSeq;
324}
325
326
327sal_Int32 SAL_CALL java_sql_Statement_Base::executeUpdate( const OUString& sql )
328{
329 ::osl::MutexGuard aGuard( m_aMutex );
330 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
331 m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_UPDATE, sql );
332
333 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
334 createStatement(t.pEnv);
336 static jmethodID mID(nullptr);
337 return callIntMethodWithStringArg("executeUpdate",mID,sql);
338}
339
340
341Reference< css::sdbc::XResultSet > SAL_CALL java_sql_Statement_Base::getResultSet( )
342{
343 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
344 createStatement(t.pEnv);
345 static jmethodID mID(nullptr);
346 jobject out = callResultSetMethod(t.env(),"getResultSet",mID);
347
348 // WARNING: the caller becomes the owner of the returned pointer
349 return out==nullptr ? nullptr : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this );
350}
351
352
354{
355 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
356 createStatement(t.pEnv);
357 static jmethodID mID(nullptr);
358 sal_Int32 out = callIntMethod_ThrowSQL("getUpdateCount", mID);
359 m_aLogger.log( LogLevel::FINER, STR_LOG_UPDATE_COUNT, out );
360 return out;
361}
362
363
365{
366 static jmethodID mID(nullptr);
367 return callBooleanMethod( "getMoreResults", mID );
368}
369
370
372{
374 createStatement(t.pEnv);
375 static jmethodID mID(nullptr);
376 jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID);
377 // WARNING: the caller becomes the owner of the returned pointer
378 if( out )
379 {
380 java_sql_SQLWarning_BASE warn_base( t.pEnv, out );
381 return Any(
382 static_cast< css::sdbc::SQLException >(
383 java_sql_SQLWarning(warn_base,getXWeak())));
384 }
385
386 return Any();
387}
388
390{
391 ::osl::MutexGuard aGuard( m_aMutex );
392 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
394
395 {
396 createStatement(t.pEnv);
397 static jmethodID mID(nullptr);
398 callVoidMethod_ThrowSQL("clearWarnings", mID);
399 }
400}
401
403{
404 static jmethodID mID(nullptr);
405 return impl_getProperty("getQueryTimeOut",mID);
406}
407
409{
410 static jmethodID mID(nullptr);
411 return impl_getProperty("getMaxRows",mID);
412}
413
415{
416 static jmethodID mID(nullptr);
417 return impl_getProperty("getResultSetConcurrency",mID,m_nResultSetConcurrency);
418}
419
420
422{
423 static jmethodID mID(nullptr);
424 return impl_getProperty("getResultSetType",mID,m_nResultSetType);
425}
426
427sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault)
428{
429 sal_Int32 out = _nDefault;
430 if ( object )
431 out = callIntMethod_ThrowRuntime(_pMethodName, _inout_MethodID);
432 return out;
433}
434
435sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID)
436{
437 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
438 createStatement(t.pEnv);
439 return callIntMethod_ThrowRuntime(_pMethodName, _inout_MethodID);
440}
441
443{
444 static jmethodID mID(nullptr);
445 return impl_getProperty("getFetchDirection",mID);
446}
447
449{
450 static jmethodID mID(nullptr);
451 return impl_getProperty("getFetchSize",mID);
452}
453
455{
456 static jmethodID mID(nullptr);
457 return impl_getProperty("getMaxFieldSize",mID);
458}
459
461{
462 ::osl::MutexGuard aGuard( m_aMutex );
463 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
464 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
465 createStatement(t.pEnv);
466 static jmethodID mID(nullptr);
467 try
468 {
469 return callStringMethod("getCursorName",mID);
470 }
471 catch(const SQLException&)
472 {
473 }
474 return OUString();
475}
476
478{
479 ::osl::MutexGuard aGuard( m_aMutex );
480 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
481 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
482 createStatement(t.pEnv);
483 static jmethodID mID(nullptr);
484 callVoidMethodWithIntArg_ThrowRuntime("setQueryTimeOut", mID, _par0);
485}
486
487
489{
490 ::osl::MutexGuard aGuard( m_aMutex );
491 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
492 m_aLogger.log( LogLevel::FINE, STR_LOG_SET_ESCAPE_PROCESSING, _par0 );
493
494 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
495 m_bEscapeProcessing = _par0;
496 createStatement( t.pEnv );
497 static jmethodID mID(nullptr);
498 callVoidMethodWithBoolArg_ThrowRuntime("setEscapeProcessing", mID, _par0);
499}
500
502{
503 ::osl::MutexGuard aGuard( m_aMutex );
504 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
505 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
506 createStatement(t.pEnv);
507 static jmethodID mID(nullptr);
508 callVoidMethodWithIntArg_ThrowRuntime("setMaxRows", mID, _par0);
509}
510
512{
513 ::osl::MutexGuard aGuard( m_aMutex );
514 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
515 m_aLogger.log( LogLevel::FINE, STR_LOG_RESULT_SET_CONCURRENCY, _par0 );
517
518 clearObject();
519}
520
522{
523 ::osl::MutexGuard aGuard( m_aMutex );
524 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
525 m_aLogger.log( LogLevel::FINE, STR_LOG_RESULT_SET_TYPE, _par0 );
526 m_nResultSetType = _par0;
527
528 clearObject();
529}
530
532{
533 ::osl::MutexGuard aGuard( m_aMutex );
534 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
535 m_aLogger.log( LogLevel::FINER, STR_LOG_FETCH_DIRECTION, _par0 );
536 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
537 createStatement(t.pEnv);
538 static jmethodID mID(nullptr);
539 callVoidMethodWithIntArg_ThrowRuntime("setFetchDirection", mID, _par0);
540}
541
543{
544 ::osl::MutexGuard aGuard( m_aMutex );
545 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
546 m_aLogger.log( LogLevel::FINER, STR_LOG_FETCH_SIZE, _par0 );
547
548 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
549 createStatement(t.pEnv);
550 static jmethodID mID(nullptr);
551 callVoidMethodWithIntArg_ThrowRuntime("setFetchSize", mID, _par0);
552}
553
555{
556 ::osl::MutexGuard aGuard( m_aMutex );
557 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
558 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
559 createStatement(t.pEnv);
560 static jmethodID mID(nullptr);
561 callVoidMethodWithIntArg_ThrowRuntime("setMaxFieldSize", mID, _par0);
562}
563
564void java_sql_Statement_Base::setCursorName(const OUString &_par0)
565{
566 ::osl::MutexGuard aGuard( m_aMutex );
567 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
568 SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java environment has been deleted!");
569 {
570 createStatement(t.pEnv);
571 static jmethodID mID(nullptr);
572 callVoidMethodWithStringArg("setCursorName",mID,_par0);
573 } //t.pEnv
574}
575
576
578{
579 return new ::cppu::OPropertyArrayHelper
580 {
581 {
582 {
586 0
587 },
588 {
592 0
593 },
594 {
598 0
599 },
600 {
604 0
605 },
606 {
610 0
611 },
612 {
616 0
617 },
618 {
622 0
623 },
624 {
628 0
629 },
630 {
634 0
635 },
636 {
640 0
641 }
642 }
643 };
644}
645
646
648
649{
650 return *getArrayHelper();
651}
652
654 Any & rConvertedValue,
655 Any & rOldValue,
656 sal_Int32 nHandle,
657 const Any& rValue )
658{
659 try
660 {
661 switch(nHandle)
662 {
664 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
666 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize());
668 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxRows());
670 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName());
672 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency());
674 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType());
676 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
678 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
680 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEscapeProcessing );
682 // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
683 default:
684 ;
685 }
686 }
687 catch(const css::lang::IllegalArgumentException&)
688 {
689 throw;
690 }
691 catch(const css::uno::Exception&)
692 {
693 DBG_UNHANDLED_EXCEPTION("connectivity.jdbc");
694 }
695 return false;
696}
697
699 sal_Int32 nHandle,
700 const Any& rValue
701 )
702{
703 switch(nHandle)
704 {
707 break;
710 break;
713 break;
716 break;
719 break;
722 break;
725 break;
728 break;
730 setEscapeProcessing( ::comphelper::getBOOL( rValue ) );
731 break;
733 // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
734 default:
735 ;
736 }
737}
738
740 Any& rValue,
741 sal_Int32 nHandle
742 ) const
743{
744 java_sql_Statement_Base* THIS = const_cast<java_sql_Statement_Base*>(this);
745 try
746 {
747 switch(nHandle)
748 {
750 rValue <<= THIS->getQueryTimeOut();
751 break;
753 rValue <<= THIS->getMaxFieldSize();
754 break;
756 rValue <<= THIS->getMaxRows();
757 break;
759 rValue <<= THIS->getCursorName();
760 break;
762 rValue <<= THIS->getResultSetConcurrency();
763 break;
765 rValue <<= THIS->getResultSetType();
766 break;
768 rValue <<= THIS->getFetchDirection();
769 break;
771 rValue <<= THIS->getFetchSize();
772 break;
774 rValue <<= m_bEscapeProcessing;
775 break;
777 default:
778 ;
779 }
780 }
781 catch(const Exception&)
782 {
783 }
784}
785
786jclass java_sql_Statement::theClass = nullptr;
787
789{}
790
792{
793 // the class must be fetched only once, therefore static
794 if( !theClass )
795 theClass = findMyClass("java/sql/Statement");
796 return theClass;
797}
798
799
801{
802 ::osl::MutexGuard aGuard( m_aMutex );
803 checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
804
805 if( !_pEnv || object )
806 return;
807
808 // initialize temporary variable
809 static const char * const cMethodName = "createStatement";
810 // Java-Call
811 jobject out = nullptr;
812 static jmethodID mID(nullptr);
813 if ( !mID )
814 {
815 static const char * const cSignature = "(II)Ljava/sql/Statement;";
816 mID = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
817 }
818 if( mID ){
819 out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID,m_nResultSetType,m_nResultSetConcurrency );
820 } //mID
821 else
822 {
823 static const char * const cSignature2 = "()Ljava/sql/Statement;";
824 static jmethodID mID2 = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,"Unknown method id!");
825 if( mID2 ){
826 out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2);
827 } //mID
828 }
829 ThrowLoggedSQLException( m_aLogger, _pEnv, *this );
830
831 if ( out )
832 object = _pEnv->NewGlobalRef( out );
833}
834
835
836IMPLEMENT_SERVICE_INFO(java_sql_Statement,"com.sun.star.sdbcx.JStatement","com.sun.star.sdbc.Statement");
837
838void SAL_CALL java_sql_Statement_Base::acquire() noexcept
839{
840 java_sql_Statement_BASE::acquire();
841}
842
843void SAL_CALL java_sql_Statement_Base::release() noexcept
844{
845 java_sql_Statement_BASE::release();
846}
847
848void SAL_CALL java_sql_Statement::acquire() noexcept
849{
851}
852
853void SAL_CALL java_sql_Statement::release() noexcept
854{
856}
857
858css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL java_sql_Statement_Base::getPropertySetInfo( )
859{
860 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
861}
862
863
864/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPLEMENT_SERVICE_INFO(java_sql_Statement,"com.sun.star.sdbcx.JStatement","com.sun.star.sdbc.Statement")
XPropertyListType t
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
virtual void SAL_CALL disposing() override
Definition: JStatement.cxx:78
void log(const sal_Int32 _nLogLevel, const OUString &rMessage)
logs a given message, without any arguments, or source class/method names
jobject callObjectMethod(JNIEnv *pEnv, const char *_pMethodName, const char *_pSignature, jmethodID &_inout_MethodID) const
Definition: Object.cxx:404
jobject callResultSetMethod(JNIEnv &_rEnv, const char *_pMethodName, jmethodID &_inout_MethodID) const
Definition: Object.cxx:279
sal_Int32 callIntMethod_ThrowSQL(const char *_pMethodName, jmethodID &_inout_MethodID) const
Definition: Object.cxx:286
bool callBooleanMethod(const char *_pMethodName, jmethodID &_inout_MethodID) const
Definition: Object.cxx:252
sal_Int32 callIntMethodWithStringArg(const char *_pMethodName, jmethodID &_inout_MethodID, const OUString &_nArgument) const
Definition: Object.cxx:444
void callVoidMethodWithStringArg(const char *_pMethodName, jmethodID &_inout_MethodID, const OUString &_nArgument) const
Definition: Object.cxx:432
void callVoidMethod_ThrowSQL(const char *_pMethodName, jmethodID &_inout_MethodID) const
Definition: Object.cxx:330
void callVoidMethodWithBoolArg_ThrowRuntime(const char *_pMethodName, jmethodID &_inout_MethodID, bool _nArgument) const
Definition: Object.cxx:384
void callVoidMethodWithIntArg_ThrowRuntime(const char *_pMethodName, jmethodID &_inout_MethodID, sal_Int32 _nArgument) const
Definition: Object.cxx:363
OUString callStringMethod(const char *_pMethodName, jmethodID &_inout_MethodID) const
Definition: Object.cxx:394
sal_Int32 callIntMethod_ThrowRuntime(const char *_pMethodName, jmethodID &_inout_MethodID) const
Definition: Object.cxx:297
static void ThrowLoggedSQLException(const ::comphelper::EventLogger &_rLogger, JNIEnv *pEnvironment, const css::uno::Reference< css::uno::XInterface > &_rxContext)
Definition: Object.cxx:197
static jclass findMyClass(const char *_pClassName)
Definition: Object.cxx:466
void callVoidMethod_ThrowRuntime(const char *_pMethodName, jmethodID &_inout_MethodID) const
Definition: Object.cxx:341
void obtainMethodId_throwSQL(JNIEnv *_pEnv, const char *_pMethodName, const char *_pSignature, jmethodID &_inout_MethodID) const
Definition: Object.cxx:229
java::sql::ConnectionLog m_aLogger
Definition: JStatement.hxx:114
virtual void SAL_CALL close() override
Definition: JStatement.cxx:187
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getGeneratedValues() override
Definition: JStatement.cxx:136
sal_Int32 impl_getProperty(const char *_pMethodName, jmethodID &_inout_MethodID)
Definition: JStatement.cxx:435
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
Definition: JStatement.cxx:279
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
Definition: JStatement.cxx:653
virtual jclass getMyClass() const override
Definition: JStatement.cxx:94
virtual css::uno::Any SAL_CALL getWarnings() override
Definition: JStatement.cxx:371
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: JStatement.cxx:647
virtual void SAL_CALL clearWarnings() override
Definition: JStatement.cxx:389
css::uno::Reference< css::sdbc::XStatement > m_xGeneratedStatement
Definition: JStatement.hxx:112
virtual sal_Bool SAL_CALL execute(const OUString &sql) override
Definition: JStatement.cxx:210
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: JStatement.cxx:118
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
Definition: JStatement.cxx:577
void setQueryTimeOut(sal_Int32 _par0)
Definition: JStatement.cxx:477
void setFetchDirection(sal_Int32 _par0)
Definition: JStatement.cxx:531
virtual sal_Bool SAL_CALL getMoreResults() override
Definition: JStatement.cxx:364
virtual sal_Int32 SAL_CALL executeUpdate(const OUString &sql) override
Definition: JStatement.cxx:327
void setFetchSize(sal_Int32 _par0)
Definition: JStatement.cxx:542
void setResultSetType(sal_Int32 _par0)
Definition: JStatement.cxx:521
virtual ~java_sql_Statement_Base() override
Definition: JStatement.cxx:73
virtual void SAL_CALL release() noexcept override
Definition: JStatement.cxx:843
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(const OUString &sql) override
Definition: JStatement.cxx:244
virtual void SAL_CALL disposing() override
Definition: JStatement.cxx:102
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
Definition: JStatement.cxx:698
virtual sal_Int32 SAL_CALL getUpdateCount() override
Definition: JStatement.cxx:353
rtl::Reference< java_sql_Connection > m_pConnection
Definition: JStatement.hxx:113
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: JStatement.cxx:858
virtual void SAL_CALL cancel() override
Definition: JStatement.cxx:178
void setCursorName(const OUString &_par0)
Definition: JStatement.cxx:564
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet() override
Definition: JStatement.cxx:341
void setResultSetConcurrency(sal_Int32 _par0)
Definition: JStatement.cxx:511
virtual void createStatement(JNIEnv *_pEnv)=0
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: JStatement.cxx:110
void setMaxFieldSize(sal_Int32 _par0)
Definition: JStatement.cxx:554
virtual void SAL_CALL acquire() noexcept override
Definition: JStatement.cxx:838
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
Definition: JStatement.cxx:739
virtual void SAL_CALL clearBatch() override
Definition: JStatement.cxx:198
virtual void createStatement(JNIEnv *_pEnv) override
Definition: JStatement.cxx:800
virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch() override
Definition: JStatement.cxx:307
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: JStatement.cxx:287
virtual ~java_sql_Statement() override
Definition: JStatement.cxx:788
virtual void SAL_CALL addBatch(const OUString &sql) override
Definition: JStatement.cxx:294
virtual void SAL_CALL acquire() noexcept override
Definition: JStatement.cxx:848
virtual jclass getMyClass() const override
Definition: JStatement.cxx:791
virtual void SAL_CALL release() noexcept override
Definition: JStatement.cxx:853
helper class to hold a local ref to a JNI object
Definition: LocalRef.hxx:42
mutable::osl::Mutex m_aMutex
css::uno::Type const & get()
const OUString & getNameByIndex(sal_Int32 _nIndex) const
Definition: propertyids.cxx:95
#define DBG_UNHANDLED_EXCEPTION(...)
std::mutex m_aMutex
void * p
Sequence< sal_Int8 > aSeq
@ Exception
sal_Int32 getINT32(const Any &_rAny)
OUString getString(const Any &_rAny)
Type
::cppu::WeakComponentImplHelper< css::sdbc::XStatement, css::sdbc::XWarningsSupplier, css::util::XCancellable, css::sdbc::XCloseable, css::sdbc::XGeneratedResultSet, css::sdbc::XMultipleResults > java_sql_Statement_BASE
Definition: JStatement.hxx:46
jstring convertwchar_tToJavaString(JNIEnv *pEnv, const OUString &Temp)
Definition: tools.cxx:93
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
enumrange< T >::Iterator begin(enumrange< T >)
end
void dispose()
#define PROPERTY_ID_RESULTSETTYPE
Definition: propertyids.hxx:44
#define PROPERTY_ID_QUERYTIMEOUT
Definition: propertyids.hxx:39
#define PROPERTY_ID_USEBOOKMARKS
Definition: propertyids.hxx:48
#define PROPERTY_ID_CURSORNAME
Definition: propertyids.hxx:42
#define PROPERTY_ID_RESULTSETCONCURRENCY
Definition: propertyids.hxx:43
#define PROPERTY_ID_MAXFIELDSIZE
Definition: propertyids.hxx:40
#define PROPERTY_ID_FETCHSIZE
Definition: propertyids.hxx:46
#define PROPERTY_ID_MAXROWS
Definition: propertyids.hxx:41
#define PROPERTY_ID_ESCAPEPROCESSING
Definition: propertyids.hxx:47
#define PROPERTY_ID_FETCHDIRECTION
Definition: propertyids.hxx:45
sal_Int32 nHandle
constexpr OUStringLiteral STR_LOG_FETCH_DIRECTION
Definition: strings.hxx:40
constexpr OUStringLiteral STR_LOG_RESULT_SET_TYPE
Definition: strings.hxx:39
constexpr OUStringLiteral STR_LOG_EXECUTE_UPDATE
Definition: strings.hxx:36
constexpr OUStringLiteral STR_LOG_CLOSING_STATEMENT
Definition: strings.hxx:35
constexpr OUStringLiteral STR_LOG_EXECUTE_QUERY
Definition: strings.hxx:34
constexpr OUStringLiteral STR_LOG_SET_ESCAPE_PROCESSING
Definition: strings.hxx:42
constexpr OUStringLiteral STR_LOG_GENERATED_VALUES
Definition: strings.hxx:31
constexpr OUStringLiteral STR_LOG_EXECUTE_STATEMENT
Definition: strings.hxx:33
constexpr OUStringLiteral STR_LOG_UPDATE_COUNT
Definition: strings.hxx:37
constexpr OUStringLiteral STR_LOG_FETCH_SIZE
Definition: strings.hxx:41
constexpr OUStringLiteral STR_LOG_RESULT_SET_CONCURRENCY
Definition: strings.hxx:38
constexpr OUStringLiteral STR_LOG_GENERATED_VALUES_FALLBACK
Definition: strings.hxx:32
unsigned char sal_Bool
const SvXMLTokenMapEntry aTypes[]