LCOV - code coverage report
Current view: top level - connectivity/source/drivers/jdbc - Object.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 161 230 70.0 %
Date: 2014-11-03 Functions: 33 42 78.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "java/lang/Class.hxx"
      21             : #include <connectivity/CommonTools.hxx>
      22             : #include <com/sun/star/uno/Exception.hpp>
      23             : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
      24             : #include "java/tools.hxx"
      25             : #include "java/sql/SQLException.hxx"
      26             : #include <osl/mutex.hxx>
      27             : #include <osl/thread.h>
      28             : #include <com/sun/star/uno/Sequence.hxx>
      29             : #include "java/LocalRef.hxx"
      30             : #include "resource/jdbc_log.hrc"
      31             : 
      32             : #include <comphelper/logging.hxx>
      33             : 
      34             : #include <boost/scoped_ptr.hpp>
      35             : 
      36             : using namespace connectivity;
      37             : using namespace ::com::sun::star::uno;
      38             : using namespace ::com::sun::star::beans;
      39             : using namespace ::com::sun::star::sdbc;
      40             : using namespace ::com::sun::star::container;
      41             : using namespace ::com::sun::star::lang;
      42             : 
      43             : 
      44             : 
      45       12720 : ::rtl::Reference< jvmaccess::VirtualMachine > getJavaVM2(const ::rtl::Reference< jvmaccess::VirtualMachine >& _rVM = ::rtl::Reference< jvmaccess::VirtualMachine >(),
      46             :                                                         bool _bSet = false)
      47             : {
      48       12720 :     static ::rtl::Reference< jvmaccess::VirtualMachine > s_VM;
      49       12720 :     if ( _rVM.is() || _bSet )
      50           6 :         s_VM = _rVM;
      51       12720 :     return s_VM;
      52             : }
      53             : 
      54       12714 : ::rtl::Reference< jvmaccess::VirtualMachine > java_lang_Object::getVM(const Reference<XComponentContext >& _rxContext)
      55             : {
      56       12714 :     ::rtl::Reference< jvmaccess::VirtualMachine > xVM = getJavaVM2();
      57       12714 :     if ( !xVM.is() && _rxContext.is() )
      58           4 :         xVM = getJavaVM2(::connectivity::getJavaVM(_rxContext));
      59             : 
      60       12714 :     return xVM;
      61             : }
      62             : 
      63       12708 : SDBThreadAttach::SDBThreadAttach()
      64             :  : m_aGuard(java_lang_Object::getVM())
      65       12708 :  , pEnv(NULL)
      66             : {
      67       12708 :     pEnv = m_aGuard.getEnvironment();
      68             :     OSL_ENSURE(pEnv,"Environment is nULL!");
      69       12708 : }
      70             : 
      71       12708 : SDBThreadAttach::~SDBThreadAttach()
      72             : {
      73       12708 : }
      74             : 
      75         302 : oslInterlockedCount& getJavaVMRefCount()
      76             : {
      77             :     static oslInterlockedCount s_nRefCount = 0;
      78         302 :     return s_nRefCount;
      79             : }
      80             : 
      81         106 : void SDBThreadAttach::addRef()
      82             : {
      83         106 :     osl_atomic_increment(&getJavaVMRefCount());
      84         106 : }
      85             : 
      86          98 : void SDBThreadAttach::releaseRef()
      87             : {
      88          98 :     osl_atomic_decrement(&getJavaVMRefCount());
      89          98 :     if ( getJavaVMRefCount() == 0 )
      90             :     {
      91           2 :         getJavaVM2(::rtl::Reference< jvmaccess::VirtualMachine >(),true);
      92             :     }
      93          98 : }
      94             : 
      95             : // static variables of the class
      96             : jclass java_lang_Object::theClass = 0;
      97             : 
      98           0 : jclass java_lang_Object::getMyClass() const
      99             : {
     100           0 :     if( !theClass )
     101           0 :         theClass = findMyClass("java/lang/Object");
     102           0 :     return theClass;
     103             : }
     104             : // the actual constructor
     105           4 : java_lang_Object::java_lang_Object()
     106           4 :             : object( 0 )
     107             : {
     108           4 :     SDBThreadAttach::addRef();
     109           4 : }
     110             : 
     111             : // the protected-constructor for the derived classes
     112          56 : java_lang_Object::java_lang_Object( JNIEnv * pXEnv, jobject myObj )
     113          56 :     : object( NULL )
     114             : {
     115          56 :     SDBThreadAttach::addRef();
     116          56 :     if( pXEnv && myObj )
     117          46 :         object = pXEnv->NewGlobalRef( myObj );
     118          56 : }
     119             : 
     120          56 : java_lang_Object::~java_lang_Object()
     121             : {
     122          56 :     if( object )
     123             :     {
     124          18 :         SDBThreadAttach t;
     125          18 :         clearObject(*t.pEnv);
     126             :     }
     127          56 :     SDBThreadAttach::releaseRef();
     128          56 : }
     129          56 : void java_lang_Object::clearObject(JNIEnv& rEnv)
     130             : {
     131          56 :     if( object )
     132             :     {
     133          56 :         rEnv.DeleteGlobalRef( object );
     134          56 :         object = NULL;
     135             :     }
     136          56 : }
     137             : 
     138           6 : void java_lang_Object::clearObject()
     139             : {
     140           6 :     if( object )
     141             :     {
     142           6 :         SDBThreadAttach t;
     143           6 :         clearObject(*t.pEnv);
     144             :     }
     145           6 : }
     146             : // the protected-constructor for the derived classes
     147           4 : void java_lang_Object::saveRef( JNIEnv * pXEnv, jobject myObj )
     148             : {
     149             :     OSL_ENSURE( myObj, "object in c++ -> Java Wrapper" );
     150           4 :     if( myObj )
     151           4 :         object = pXEnv->NewGlobalRef( myObj );
     152           4 : }
     153             : 
     154             : 
     155           0 : OUString java_lang_Object::toString() const
     156             : {
     157             :     static jmethodID mID(NULL);
     158           0 :     return callStringMethod("toString",mID);
     159             : }
     160             : 
     161             : 
     162             : namespace
     163             : {
     164       12594 :     bool    lcl_translateJNIExceptionToUNOException(
     165             :         JNIEnv* _pEnvironment, const Reference< XInterface >& _rxContext, SQLException& _out_rException )
     166             :     {
     167       12594 :         jthrowable jThrow = _pEnvironment ? _pEnvironment->ExceptionOccurred() : NULL;
     168       12594 :         if ( !jThrow )
     169       12594 :             return false;
     170             : 
     171           0 :         _pEnvironment->ExceptionClear();
     172             :             // we have to clear the exception here because we want to handle it itself
     173             : 
     174           0 :         if ( _pEnvironment->IsInstanceOf( jThrow, java_sql_SQLException_BASE::st_getMyClass() ) )
     175             :         {
     176           0 :             boost::scoped_ptr< java_sql_SQLException_BASE > pException( new java_sql_SQLException_BASE( _pEnvironment, jThrow ) );
     177           0 :             _out_rException = SQLException( pException->getMessage(), _rxContext,
     178           0 :                 pException->getSQLState(), pException->getErrorCode(), Any() );
     179           0 :             return true;
     180             :         }
     181           0 :         else if ( _pEnvironment->IsInstanceOf( jThrow, java_lang_Throwable::st_getMyClass() ) )
     182             :         {
     183           0 :             boost::scoped_ptr< java_lang_Throwable > pThrow( new java_lang_Throwable( _pEnvironment, jThrow ) );
     184             : #if OSL_DEBUG_LEVEL > 0
     185             :             pThrow->printStackTrace();
     186             : #endif
     187           0 :             OUString sMessage = pThrow->getMessage();
     188           0 :             if ( sMessage.isEmpty() )
     189           0 :                 sMessage = pThrow->getLocalizedMessage();
     190           0 :             if(  sMessage.isEmpty() )
     191           0 :                 sMessage = pThrow->toString();
     192           0 :             _out_rException = SQLException( sMessage, _rxContext, OUString(), -1, Any() );
     193           0 :             return true;
     194             :         }
     195             :         else
     196           0 :             _pEnvironment->DeleteLocalRef( jThrow );
     197           0 :         return false;
     198             :     }
     199             : }
     200             : 
     201             : 
     202          38 : void java_lang_Object::ThrowLoggedSQLException( const ::comphelper::ResourceBasedEventLogger& _rLogger, JNIEnv* _pEnvironment,
     203             :     const Reference< XInterface >& _rxContext )
     204             : {
     205          38 :     SQLException aException;
     206          38 :     if ( lcl_translateJNIExceptionToUNOException( _pEnvironment, _rxContext, aException ) )
     207             :     {
     208           0 :         _rLogger.log( ::com::sun::star::logging::LogLevel::SEVERE, STR_LOG_THROWING_EXCEPTION, aException.Message, aException.SQLState, aException.ErrorCode );
     209           0 :         throw aException;
     210          38 :     }
     211          38 : }
     212             : 
     213       12556 : void java_lang_Object::ThrowSQLException( JNIEnv* _pEnvironment, const Reference< XInterface>& _rxContext )
     214             : {
     215       12556 :     SQLException aException;
     216       12556 :     if ( lcl_translateJNIExceptionToUNOException( _pEnvironment, _rxContext, aException ) )
     217           0 :         throw aException;
     218       12556 : }
     219             : 
     220          14 : void java_lang_Object::ThrowRuntimeException( JNIEnv* _pEnvironment, const Reference< XInterface>& _rxContext )
     221             : {
     222             :     try
     223             :     {
     224          14 :         ThrowSQLException(_pEnvironment, _rxContext);
     225             :     }
     226           0 :     catch (const SQLException& e)
     227             :     {
     228           0 :         throw WrappedTargetRuntimeException(e.Message, e.Context, makeAny(e));
     229             :     }
     230          14 : }
     231             : 
     232       12558 : void java_lang_Object::obtainMethodId_throwSQL(JNIEnv* _pEnv,const char* _pMethodName, const char* _pSignature,jmethodID& _inout_MethodID) const
     233             : {
     234       12558 :     if  ( !_inout_MethodID )
     235             :     {
     236         102 :         _inout_MethodID  = _pEnv->GetMethodID( getMyClass(), _pMethodName, _pSignature );
     237             :         OSL_ENSURE( _inout_MethodID, _pSignature );
     238         102 :         if  ( !_inout_MethodID )
     239           0 :             throw SQLException();
     240             :     } // if  ( !_inout_MethodID )
     241       12558 : }
     242             : 
     243          14 : void java_lang_Object::obtainMethodId_throwRuntime(JNIEnv* _pEnv,const char* _pMethodName, const char* _pSignature,jmethodID& _inout_MethodID) const
     244             : {
     245          14 :     if  ( !_inout_MethodID )
     246             :     {
     247           6 :         _inout_MethodID  = _pEnv->GetMethodID( getMyClass(), _pMethodName, _pSignature );
     248             :         OSL_ENSURE( _inout_MethodID, _pSignature );
     249           6 :         if  ( !_inout_MethodID )
     250           0 :             throw RuntimeException();
     251             :     } // if  ( !_inout_MethodID )
     252          14 : }
     253             : 
     254             : 
     255        4164 : bool java_lang_Object::callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const
     256             : {
     257        4164 :     jboolean out( sal_False );
     258             : 
     259        4164 :     SDBThreadAttach t;
     260             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callBooleanMethod: no Java environment anymore!" );
     261        4164 :     obtainMethodId_throwSQL(t.pEnv, _pMethodName,"()Z", _inout_MethodID);
     262             :     // call method
     263        4164 :     out = t.pEnv->CallBooleanMethod( object, _inout_MethodID );
     264        4164 :     ThrowSQLException( t.pEnv, NULL );
     265             : 
     266        4164 :     return out;
     267             : }
     268             : 
     269          12 : bool java_lang_Object::callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const
     270             : {
     271          12 :     jboolean out( sal_False );
     272          12 :     SDBThreadAttach t;
     273             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callBooleanMethodWithIntArg: no Java environment anymore!" );
     274          12 :     obtainMethodId_throwSQL(t.pEnv, _pMethodName,"(I)Z", _inout_MethodID);
     275             :     // call method
     276          12 :     out = t.pEnv->CallBooleanMethod( object, _inout_MethodID, _nArgument );
     277          12 :     ThrowSQLException( t.pEnv, NULL );
     278             : 
     279          12 :     return out;
     280             : }
     281             : 
     282           4 : jobject java_lang_Object::callResultSetMethod( JNIEnv& _rEnv,const char* _pMethodName, jmethodID& _inout_MethodID ) const
     283             : {
     284             :     // call method
     285           4 :     jobject out = callObjectMethod(&_rEnv,_pMethodName,"()Ljava/sql/ResultSet;", _inout_MethodID);
     286           4 :     return out;
     287             : }
     288             : 
     289          12 : sal_Int32 java_lang_Object::callIntMethod_ThrowSQL(const char* _pMethodName, jmethodID& _inout_MethodID) const
     290             : {
     291          12 :     SDBThreadAttach t;
     292             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     293          12 :     obtainMethodId_throwSQL(t.pEnv, _pMethodName,"()I", _inout_MethodID);
     294             :     // call method
     295          12 :     jint out( t.pEnv->CallIntMethod( object, _inout_MethodID ) );
     296          12 :     ThrowSQLException( t.pEnv, NULL );
     297          12 :     return (sal_Int32)out;
     298             : }
     299             : 
     300          12 : sal_Int32 java_lang_Object::callIntMethod_ThrowRuntime(const char* _pMethodName, jmethodID& _inout_MethodID) const
     301             : {
     302          12 :     SDBThreadAttach t;
     303             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     304          12 :     obtainMethodId_throwRuntime(t.pEnv, _pMethodName,"()I", _inout_MethodID);
     305             :     // call method
     306          12 :     jint out( t.pEnv->CallIntMethod( object, _inout_MethodID ) );
     307          12 :     ThrowRuntimeException(t.pEnv, NULL);
     308          12 :     return (sal_Int32)out;
     309             : }
     310             : 
     311          52 : sal_Int32 java_lang_Object::callIntMethodWithIntArg_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nArgument ) const
     312             : {
     313          52 :     SDBThreadAttach t;
     314             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     315          52 :     obtainMethodId_throwSQL(t.pEnv, _pMethodName,"(I)I", _inout_MethodID);
     316             :     // call method
     317          52 :     jint out( t.pEnv->CallIntMethod( object, _inout_MethodID , _nArgument) );
     318          52 :     ThrowSQLException( t.pEnv, NULL );
     319          52 :     return (sal_Int32)out;
     320             : }
     321             : 
     322           0 : sal_Int32 java_lang_Object::callIntMethodWithIntArg_ThrowRuntime( const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nArgument ) const
     323             : {
     324           0 :     SDBThreadAttach t;
     325             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     326           0 :     obtainMethodId_throwRuntime(t.pEnv, _pMethodName,"(I)I", _inout_MethodID);
     327             :     // call method
     328           0 :     jint out( t.pEnv->CallIntMethod( object, _inout_MethodID , _nArgument) );
     329           0 :     ThrowRuntimeException(t.pEnv, NULL);
     330           0 :     return (sal_Int32)out;
     331             : }
     332             : 
     333          38 : void java_lang_Object::callVoidMethod_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID) const
     334             : {
     335          38 :     SDBThreadAttach t;
     336             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     337          38 :     obtainMethodId_throwSQL(t.pEnv, _pMethodName,"()V", _inout_MethodID);
     338             : 
     339             :     // call method
     340          38 :     t.pEnv->CallVoidMethod( object, _inout_MethodID );
     341          38 :     ThrowSQLException( t.pEnv, NULL );
     342          38 : }
     343             : 
     344           0 : void java_lang_Object::callVoidMethod_ThrowRuntime( const char* _pMethodName, jmethodID& _inout_MethodID) const
     345             : {
     346           0 :     SDBThreadAttach t;
     347             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     348           0 :     obtainMethodId_throwRuntime(t.pEnv, _pMethodName,"()V", _inout_MethodID);
     349             : 
     350             :     // call method
     351           0 :     t.pEnv->CallVoidMethod( object, _inout_MethodID );
     352           0 :     ThrowRuntimeException(t.pEnv, NULL);
     353           0 : }
     354             : 
     355           0 : void java_lang_Object::callVoidMethodWithIntArg_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const
     356             : {
     357           0 :     SDBThreadAttach t;
     358             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     359           0 :     obtainMethodId_throwSQL(t.pEnv, _pMethodName,"(I)V", _inout_MethodID);
     360             : 
     361             :     // call method
     362           0 :     t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument );
     363           0 :     ThrowSQLException( t.pEnv, NULL );
     364           0 : }
     365             : 
     366           0 : void java_lang_Object::callVoidMethodWithIntArg_ThrowRuntime( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const
     367             : {
     368           0 :     SDBThreadAttach t;
     369             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     370           0 :     obtainMethodId_throwRuntime(t.pEnv, _pMethodName,"(I)V", _inout_MethodID);
     371             : 
     372             :     // call method
     373           0 :     t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument );
     374           0 :     ThrowRuntimeException(t.pEnv, NULL);
     375           0 : }
     376             : 
     377           0 : void java_lang_Object::callVoidMethodWithBoolArg_ThrowSQL( const char* _pMethodName, jmethodID& _inout_MethodID, bool _nArgument ) const
     378             : {
     379           0 :     SDBThreadAttach t;
     380             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     381           0 :     obtainMethodId_throwSQL(t.pEnv, _pMethodName,"(Z)V", _inout_MethodID);
     382             :     // call method
     383           0 :     t.pEnv->CallVoidMethod( object, _inout_MethodID,int(_nArgument) );
     384           0 :     ThrowSQLException( t.pEnv, NULL );
     385           0 : }
     386             : 
     387           2 : void java_lang_Object::callVoidMethodWithBoolArg_ThrowRuntime( const char* _pMethodName, jmethodID& _inout_MethodID, bool _nArgument ) const
     388             : {
     389           2 :     SDBThreadAttach t;
     390             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     391           2 :     obtainMethodId_throwRuntime(t.pEnv, _pMethodName,"(Z)V", _inout_MethodID);
     392             :     // call method
     393           2 :     t.pEnv->CallVoidMethod( object, _inout_MethodID,int(_nArgument) );
     394           2 :     ThrowRuntimeException(t.pEnv, NULL);
     395           2 : }
     396             : 
     397           8 : OUString java_lang_Object::callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const
     398             : {
     399           8 :     SDBThreadAttach t;
     400             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callStringMethod: no Java environment anymore!" );
     401             : 
     402             :     // call method
     403           8 :     jstring out = static_cast<jstring>(callObjectMethod(t.pEnv,_pMethodName,"()Ljava/lang/String;", _inout_MethodID));
     404           8 :     return JavaString2String( t.pEnv, out );
     405             : }
     406             : 
     407          28 : jobject java_lang_Object::callObjectMethod( JNIEnv * _pEnv,const char* _pMethodName,const char* _pSignature, jmethodID& _inout_MethodID ) const
     408             : {
     409             :     // obtain method ID
     410          28 :     obtainMethodId_throwSQL(_pEnv, _pMethodName,_pSignature, _inout_MethodID);
     411             :     // call method
     412          28 :     jobject out = _pEnv->CallObjectMethod( object, _inout_MethodID);
     413          28 :     ThrowSQLException( _pEnv, NULL );
     414          28 :     return out;
     415             : }
     416             : 
     417             : 
     418        8198 : jobject java_lang_Object::callObjectMethodWithIntArg( JNIEnv * _pEnv,const char* _pMethodName,const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const
     419             : {
     420        8198 :     obtainMethodId_throwSQL(_pEnv, _pMethodName,_pSignature, _inout_MethodID);
     421             :     // call method
     422        8198 :     jobject out = _pEnv->CallObjectMethod( object, _inout_MethodID,_nArgument );
     423        8198 :     ThrowSQLException( _pEnv, NULL );
     424        8198 :     return out;
     425             : }
     426             : 
     427        8198 : OUString java_lang_Object::callStringMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const
     428             : {
     429        8198 :     SDBThreadAttach t;
     430             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callStringMethod: no Java environment anymore!" );
     431        8198 :     jstring out = static_cast<jstring>(callObjectMethodWithIntArg(t.pEnv,_pMethodName,"(I)Ljava/lang/String;",_inout_MethodID,_nArgument));
     432        8198 :     return JavaString2String( t.pEnv, out );
     433             : }
     434             : 
     435           0 : void java_lang_Object::callVoidMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const OUString& _nArgument ) const
     436             : {
     437           0 :     SDBThreadAttach t;
     438             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java environment anymore!" );
     439           0 :     obtainMethodId_throwSQL(t.pEnv, _pMethodName,"(Ljava/lang/String;)V", _inout_MethodID);
     440             : 
     441           0 :     jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument));
     442             :     // call method
     443           0 :     t.pEnv->CallVoidMethod( object, _inout_MethodID , str.get());
     444           0 :     ThrowSQLException( t.pEnv, NULL );
     445           0 : }
     446             : 
     447           6 : sal_Int32 java_lang_Object::callIntMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const OUString& _nArgument ) const
     448             : {
     449           6 :     SDBThreadAttach t;
     450             :     OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethodWithStringArg: no Java environment anymore!" );
     451           6 :     obtainMethodId_throwSQL(t.pEnv, _pMethodName,"(Ljava/lang/String;)I", _inout_MethodID);
     452             : 
     453             :     //TODO: Check if the code below is needed
     454             :             //jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
     455             :             //{
     456             :             //    jdbc::ContextClassLoaderScope ccl( t.env(),
     457             :             //        m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
     458             :             //        m_aLogger,
     459             :             //        *this
     460             :             //    );
     461             : 
     462          12 :     jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument));
     463             :     // call method
     464           6 :     jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str.get());
     465           6 :     ThrowSQLException( t.pEnv, NULL );
     466          12 :     return (sal_Int32)out;
     467             : }
     468             : 
     469          38 : jclass java_lang_Object::findMyClass(const char* _pClassName)
     470             : {
     471             :     // the class must be fetched only once, therefore static
     472          38 :     SDBThreadAttach t;
     473          38 :     jclass tempClass = t.pEnv->FindClass(_pClassName); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
     474          38 :     if(!tempClass)
     475             :     {
     476           0 :         t.pEnv->ExceptionDescribe();
     477           0 :         t.pEnv->ExceptionClear();
     478             :     }
     479          38 :     jclass globClass = static_cast<jclass>(t.pEnv->NewGlobalRef( tempClass ));
     480          38 :     t.pEnv->DeleteLocalRef( tempClass );
     481          38 :     return globClass;
     482             : }
     483             : 
     484             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10