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