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

Generated by: LCOV version 1.11