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

Generated by: LCOV version 1.10