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 #include "java/sql/PreparedStatement.hxx" 31*cdf0e10cSrcweir #include "java/sql/ResultSet.hxx" 32*cdf0e10cSrcweir #include "java/sql/ResultSetMetaData.hxx" 33*cdf0e10cSrcweir #include "java/sql/Connection.hxx" 34*cdf0e10cSrcweir #include "java/sql/Timestamp.hxx" 35*cdf0e10cSrcweir #include "java/math/BigDecimal.hxx" 36*cdf0e10cSrcweir #include "java/tools.hxx" 37*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 38*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 39*cdf0e10cSrcweir #include "connectivity/dbtools.hxx" 40*cdf0e10cSrcweir #include "connectivity/FValue.hxx" 41*cdf0e10cSrcweir #include "connectivity/dbexception.hxx" 42*cdf0e10cSrcweir #include "resource/jdbc_log.hrc" 43*cdf0e10cSrcweir #include "resource/common_res.hrc" 44*cdf0e10cSrcweir #include "resource/sharedresources.hxx" 45*cdf0e10cSrcweir #include "java/LocalRef.hxx" 46*cdf0e10cSrcweir #include <string.h> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir using namespace connectivity; 49*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 50*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 51*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 52*cdf0e10cSrcweir using namespace ::com::sun::star::container; 53*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir //************************************************************** 56*cdf0e10cSrcweir //************ Class: java.sql.PreparedStatement 57*cdf0e10cSrcweir //************************************************************** 58*cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(java_sql_PreparedStatement,"com.sun.star.sdbcx.JPreparedStatement","com.sun.star.sdbc.PreparedStatement"); 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir java_sql_PreparedStatement::java_sql_PreparedStatement( JNIEnv * pEnv, java_sql_Connection& _rCon, const ::rtl::OUString& sql ) 61*cdf0e10cSrcweir : OStatement_BASE2( pEnv, _rCon ) 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir m_sSqlStatement = sql; 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 66*cdf0e10cSrcweir jclass java_sql_PreparedStatement::theClass = 0; 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir java_sql_PreparedStatement::~java_sql_PreparedStatement() 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir jclass java_sql_PreparedStatement::getMyClass() const 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir // die Klasse muss nur einmal geholt werden, daher statisch 76*cdf0e10cSrcweir if( !theClass ) 77*cdf0e10cSrcweir theClass = findMyClass("java/sql/PreparedStatement"); 78*cdf0e10cSrcweir return theClass; 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir // ------------------------------------------------------------------------- 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir ::com::sun::star::uno::Any SAL_CALL java_sql_PreparedStatement::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir ::com::sun::star::uno::Any aRet = OStatement_BASE2::queryInterface(rType); 85*cdf0e10cSrcweir return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType, 86*cdf0e10cSrcweir static_cast< XPreparedStatement*>(this), 87*cdf0e10cSrcweir static_cast< XParameters*>(this), 88*cdf0e10cSrcweir static_cast< XResultSetMetaDataSupplier*>(this), 89*cdf0e10cSrcweir static_cast< XPreparedBatchExecution*>(this)); 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir // ------------------------------------------------------------------------- 92*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_PreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ), 95*cdf0e10cSrcweir ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ), 96*cdf0e10cSrcweir ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 ), 97*cdf0e10cSrcweir ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedBatchExecution > *)0 )); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE2::getTypes()); 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir // ------------------------------------------------------------------------- 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_PreparedStatement::execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED ); 106*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 107*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir static jmethodID mID(NULL); 110*cdf0e10cSrcweir return callBooleanMethod( "execute", mID ); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir // ------------------------------------------------------------------------- 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir sal_Int32 SAL_CALL java_sql_PreparedStatement::executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 117*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 118*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_UPDATE ); 119*cdf0e10cSrcweir static jmethodID mID(NULL); 120*cdf0e10cSrcweir return callIntMethod("executeUpdate",mID); 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir // ------------------------------------------------------------------------- 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 127*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 128*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_STRING_PARAMETER, parameterIndex, x ); 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 131*cdf0e10cSrcweir { // temporaere Variable initialisieren 132*cdf0e10cSrcweir createStatement(t.pEnv); 133*cdf0e10cSrcweir static const char * cSignature = "(ILjava/lang/String;)V"; 134*cdf0e10cSrcweir static const char * cMethodName = "setString"; 135*cdf0e10cSrcweir // Java-Call absetzen 136*cdf0e10cSrcweir static jmethodID mID(NULL); 137*cdf0e10cSrcweir obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 138*cdf0e10cSrcweir jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x)); 139*cdf0e10cSrcweir t.pEnv->CallVoidMethod( object, mID, parameterIndex,str.get()); 140*cdf0e10cSrcweir // und aufraeumen 141*cdf0e10cSrcweir ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); 142*cdf0e10cSrcweir } //t.pEnv 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir // ------------------------------------------------------------------------- 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL java_sql_PreparedStatement::getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir return (Reference< XConnection >)m_pConnection; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir // ------------------------------------------------------------------------- 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_PreparedStatement::executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_QUERY ); 155*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 156*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 159*cdf0e10cSrcweir createStatement(t.pEnv); 160*cdf0e10cSrcweir static jmethodID mID(NULL); 161*cdf0e10cSrcweir jobject out = callResultSetMethod(t.env(),"executeQuery",mID); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir // ------------------------------------------------------------------------- 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_BOOLEAN_PARAMETER, parameterIndex, x ); 170*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 171*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 174*cdf0e10cSrcweir createStatement(t.pEnv); 175*cdf0e10cSrcweir static jmethodID mID(NULL); 176*cdf0e10cSrcweir callVoidMethod("setBoolean", "(IZ)V", mID, parameterIndex, x); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir // ------------------------------------------------------------------------- 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_BYTE_PARAMETER, parameterIndex, (sal_Int32)x ); 183*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 184*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 187*cdf0e10cSrcweir createStatement(t.pEnv); 188*cdf0e10cSrcweir static jmethodID mID(NULL); 189*cdf0e10cSrcweir callVoidMethod("setByte", "(IB)V", mID, parameterIndex, x); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir // ------------------------------------------------------------------------- 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_DATE_PARAMETER, parameterIndex, x ); 196*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 197*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 200*cdf0e10cSrcweir createStatement(t.pEnv); 201*cdf0e10cSrcweir java_sql_Date aT(x); 202*cdf0e10cSrcweir static jmethodID mID(NULL); 203*cdf0e10cSrcweir callVoidMethod("setDate", "(ILjava/sql/Date;)V", mID, parameterIndex, aT.getJavaObject()); 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir // ------------------------------------------------------------------------- 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_TIME_PARAMETER, parameterIndex, x ); 211*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 212*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 215*cdf0e10cSrcweir createStatement(t.pEnv); 216*cdf0e10cSrcweir java_sql_Time aT(x); 217*cdf0e10cSrcweir static jmethodID mID(NULL); 218*cdf0e10cSrcweir callVoidMethod("setTime", "(ILjava/sql/Time;)V", mID, parameterIndex, aT.getJavaObject()); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir // ------------------------------------------------------------------------- 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_TIMESTAMP_PARAMETER, parameterIndex, x ); 225*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 226*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 229*cdf0e10cSrcweir createStatement(t.pEnv); 230*cdf0e10cSrcweir static jmethodID mID(NULL); 231*cdf0e10cSrcweir java_sql_Timestamp aD(x); 232*cdf0e10cSrcweir callVoidMethod("setTimestamp", "(ILjava/sql/Timestamp;)V", mID, parameterIndex, aD.getJavaObject()); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir // ------------------------------------------------------------------------- 235*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_DOUBLE_PARAMETER, parameterIndex, x ); 238*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 239*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 242*cdf0e10cSrcweir createStatement(t.pEnv); 243*cdf0e10cSrcweir static jmethodID mID(NULL); 244*cdf0e10cSrcweir callVoidMethod("setDouble", "(ID)V", mID, parameterIndex, x); 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir // ------------------------------------------------------------------------- 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_FLOAT_PARAMETER, parameterIndex, x ); 251*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 252*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 255*cdf0e10cSrcweir createStatement(t.pEnv); 256*cdf0e10cSrcweir static jmethodID mID(NULL); 257*cdf0e10cSrcweir callVoidMethod("setFloat", "(IF)V", mID, parameterIndex, x); 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir // ------------------------------------------------------------------------- 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_INT_PARAMETER, parameterIndex, x ); 264*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 265*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 268*cdf0e10cSrcweir createStatement(t.pEnv); 269*cdf0e10cSrcweir static jmethodID mID(NULL); 270*cdf0e10cSrcweir callVoidMethod("setInt", "(II)V", mID, parameterIndex, x); 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir // ------------------------------------------------------------------------- 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_LONG_PARAMETER, parameterIndex, x ); 277*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 278*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 281*cdf0e10cSrcweir createStatement(t.pEnv); 282*cdf0e10cSrcweir static jmethodID mID(NULL); 283*cdf0e10cSrcweir callVoidMethod("setLong", "(IJ)V", mID, parameterIndex, x); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir // ------------------------------------------------------------------------- 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_NULL_PARAMETER, parameterIndex, sqlType ); 290*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 291*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 294*cdf0e10cSrcweir createStatement(t.pEnv); 295*cdf0e10cSrcweir static jmethodID mID(NULL); 296*cdf0e10cSrcweir callVoidMethod("setNull", "(II)V", mID, parameterIndex, sqlType); 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir // ------------------------------------------------------------------------- 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this ); 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir // ------------------------------------------------------------------------- 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this ); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir // ------------------------------------------------------------------------- 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 313*cdf0e10cSrcweir { 314*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this ); 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir // ------------------------------------------------------------------------- 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this ); 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir // ------------------------------------------------------------------------- 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_OBJECT_NULL_PARAMETER, parameterIndex ); 327*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 328*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir createStatement(t.pEnv); 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir // temporaere Variable initialisieren 335*cdf0e10cSrcweir static const char * cSignature = "(ILjava/lang/Object;II)V"; 336*cdf0e10cSrcweir static const char * cMethodName = "setObject"; 337*cdf0e10cSrcweir // Java-Call absetzen 338*cdf0e10cSrcweir static jmethodID mID(NULL); 339*cdf0e10cSrcweir obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir jobject obj = NULL; 342*cdf0e10cSrcweir double nTemp = 0.0; 343*cdf0e10cSrcweir switch(targetSqlType) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir case DataType::DECIMAL: 346*cdf0e10cSrcweir case DataType::NUMERIC: 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir ::std::auto_ptr<java_math_BigDecimal> pBigDecimal; 349*cdf0e10cSrcweir if ( x >>= nTemp) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir pBigDecimal.reset(new java_math_BigDecimal(nTemp)); 352*cdf0e10cSrcweir //setDouble(parameterIndex,nTemp); 353*cdf0e10cSrcweir //return; 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir else 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir ORowSetValue aValue; 358*cdf0e10cSrcweir aValue.fill(x); 359*cdf0e10cSrcweir const ::rtl::OUString sValue = aValue; 360*cdf0e10cSrcweir if ( sValue.getLength() ) 361*cdf0e10cSrcweir pBigDecimal.reset(new java_math_BigDecimal(sValue)); 362*cdf0e10cSrcweir else 363*cdf0e10cSrcweir pBigDecimal.reset(new java_math_BigDecimal(0.0)); 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir //obj = convertwchar_tToJavaString(t.pEnv,::comphelper::getString(x)); 366*cdf0e10cSrcweir t.pEnv->CallVoidMethod( object, mID, parameterIndex,pBigDecimal->getJavaObject(),targetSqlType,scale); 367*cdf0e10cSrcweir ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); 368*cdf0e10cSrcweir return; 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir default: 371*cdf0e10cSrcweir obj = convertwchar_tToJavaString(t.pEnv,::comphelper::getString(x)); 372*cdf0e10cSrcweir break; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir t.pEnv->CallVoidMethod( object, mID, parameterIndex,obj,targetSqlType,scale); 375*cdf0e10cSrcweir t.pEnv->DeleteLocalRef(obj); 376*cdf0e10cSrcweir ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); 377*cdf0e10cSrcweir // und aufraeumen 378*cdf0e10cSrcweir } //mID 379*cdf0e10cSrcweir } //t.pEnv 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir // ------------------------------------------------------------------------- 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/, const ::rtl::OUString& /*typeName*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_OBJECT_NULL_PARAMETER, parameterIndex ); 386*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 387*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 390*cdf0e10cSrcweir createStatement(t.pEnv); 391*cdf0e10cSrcweir static jmethodID mID(NULL); 392*cdf0e10cSrcweir callVoidMethod<jobject>("setObject", "(ILjava/lang/Object;)V", mID, parameterIndex, NULL); 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir // ------------------------------------------------------------------------- 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir if(!::dbtools::implSetObject(this,parameterIndex,x)) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution( 401*cdf0e10cSrcweir STR_UNKNOWN_PARA_TYPE, 402*cdf0e10cSrcweir "$position$", ::rtl::OUString::valueOf(parameterIndex) 403*cdf0e10cSrcweir ) ); 404*cdf0e10cSrcweir ::dbtools::throwGenericSQLException(sError,*this); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir // ------------------------------------------------------------------------- 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_SHORT_PARAMETER, parameterIndex, x ); 412*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 413*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 416*cdf0e10cSrcweir createStatement(t.pEnv); 417*cdf0e10cSrcweir static jmethodID mID(NULL); 418*cdf0e10cSrcweir callVoidMethod("setShort", "(IS)V", mID, parameterIndex, x); 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir // ------------------------------------------------------------------------- 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_BYTES_PARAMETER, parameterIndex ); 425*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 426*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir createStatement(t.pEnv); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir // temporaere Variable initialisieren 433*cdf0e10cSrcweir static const char * cSignature = "(I[B)V"; 434*cdf0e10cSrcweir static const char * cMethodName = "setBytes"; 435*cdf0e10cSrcweir // Java-Call absetzen 436*cdf0e10cSrcweir static jmethodID mID(NULL); 437*cdf0e10cSrcweir obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 438*cdf0e10cSrcweir jbyteArray pByteArray = t.pEnv->NewByteArray(x.getLength()); 439*cdf0e10cSrcweir t.pEnv->SetByteArrayRegion(pByteArray,0,x.getLength(),(jbyte*)x.getConstArray()); 440*cdf0e10cSrcweir t.pEnv->CallVoidMethod( object, mID, parameterIndex,pByteArray); 441*cdf0e10cSrcweir t.pEnv->DeleteLocalRef(pByteArray); 442*cdf0e10cSrcweir ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); 443*cdf0e10cSrcweir } //t.pEnv 444*cdf0e10cSrcweir } 445*cdf0e10cSrcweir // ------------------------------------------------------------------------- 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_CHARSTREAM_PARAMETER, parameterIndex ); 450*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 451*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir createStatement(t.pEnv); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir // temporaere Variable initialisieren 458*cdf0e10cSrcweir static const char * cSignature = "(ILjava/io/InputStream;I)V"; 459*cdf0e10cSrcweir static const char * cMethodName = "setCharacterStream"; 460*cdf0e10cSrcweir // Java-Call absetzen 461*cdf0e10cSrcweir static jmethodID mID(NULL); 462*cdf0e10cSrcweir obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 463*cdf0e10cSrcweir Sequence< sal_Int8 > aSeq; 464*cdf0e10cSrcweir if ( x.is() ) 465*cdf0e10cSrcweir x->readBytes( aSeq, length ); 466*cdf0e10cSrcweir sal_Int32 actualLength = aSeq.getLength(); 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir jvalue args2[3]; 469*cdf0e10cSrcweir jbyteArray pByteArray = t.pEnv->NewByteArray( actualLength ); 470*cdf0e10cSrcweir t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,(jbyte*)aSeq.getConstArray()); 471*cdf0e10cSrcweir args2[0].l = pByteArray; 472*cdf0e10cSrcweir args2[1].i = 0; 473*cdf0e10cSrcweir args2[2].i = actualLength; 474*cdf0e10cSrcweir // temporaere Variable initialisieren 475*cdf0e10cSrcweir const char * cSignatureStream = "([BII)V"; 476*cdf0e10cSrcweir // Java-Call absetzen 477*cdf0e10cSrcweir jclass aClass = t.pEnv->FindClass("java/io/CharArrayInputStream"); 478*cdf0e10cSrcweir static jmethodID mID2 = NULL; 479*cdf0e10cSrcweir if ( !mID2 ) 480*cdf0e10cSrcweir mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream ); 481*cdf0e10cSrcweir jobject tempObj = NULL; 482*cdf0e10cSrcweir if(mID2) 483*cdf0e10cSrcweir tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 ); 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir t.pEnv->CallVoidMethod( object, mID, parameterIndex,tempObj,actualLength); 486*cdf0e10cSrcweir // und aufraeumen 487*cdf0e10cSrcweir t.pEnv->DeleteLocalRef(pByteArray); 488*cdf0e10cSrcweir t.pEnv->DeleteLocalRef(tempObj); 489*cdf0e10cSrcweir t.pEnv->DeleteLocalRef(aClass); 490*cdf0e10cSrcweir ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); 491*cdf0e10cSrcweir } //t.pEnv 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir // ------------------------------------------------------------------------- 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_BINARYSTREAM_PARAMETER, parameterIndex ); 498*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 499*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir createStatement(t.pEnv); 504*cdf0e10cSrcweir // temporaere Variable initialisieren 505*cdf0e10cSrcweir static const char * cSignature = "(ILjava/io/InputStream;I)V"; 506*cdf0e10cSrcweir static const char * cMethodName = "setBinaryStream"; 507*cdf0e10cSrcweir // Java-Call absetzen 508*cdf0e10cSrcweir static jmethodID mID(NULL); 509*cdf0e10cSrcweir obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir Sequence< sal_Int8 > aSeq; 512*cdf0e10cSrcweir if ( x.is() ) 513*cdf0e10cSrcweir x->readBytes( aSeq, length ); 514*cdf0e10cSrcweir sal_Int32 actualLength = aSeq.getLength(); 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir jvalue args2[3]; 517*cdf0e10cSrcweir jbyteArray pByteArray = t.pEnv->NewByteArray(actualLength); 518*cdf0e10cSrcweir t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,(jbyte*)aSeq.getConstArray()); 519*cdf0e10cSrcweir args2[0].l = pByteArray; 520*cdf0e10cSrcweir args2[1].i = 0; 521*cdf0e10cSrcweir args2[2].i = (sal_Int32)actualLength; 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir // temporaere Variable initialisieren 524*cdf0e10cSrcweir const char * cSignatureStream = "([BII)V"; 525*cdf0e10cSrcweir // Java-Call absetzen 526*cdf0e10cSrcweir jclass aClass = t.pEnv->FindClass("java/io/ByteArrayInputStream"); 527*cdf0e10cSrcweir static jmethodID mID2 = NULL; 528*cdf0e10cSrcweir if ( !mID2 ) 529*cdf0e10cSrcweir mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream ); 530*cdf0e10cSrcweir jobject tempObj = NULL; 531*cdf0e10cSrcweir if(mID2) 532*cdf0e10cSrcweir tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 ); 533*cdf0e10cSrcweir t.pEnv->CallVoidMethod( object, mID, parameterIndex,tempObj,(sal_Int32)actualLength); 534*cdf0e10cSrcweir // und aufraeumen 535*cdf0e10cSrcweir t.pEnv->DeleteLocalRef(pByteArray); 536*cdf0e10cSrcweir t.pEnv->DeleteLocalRef(tempObj); 537*cdf0e10cSrcweir t.pEnv->DeleteLocalRef(aClass); 538*cdf0e10cSrcweir ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir } //t.pEnv 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir // ------------------------------------------------------------------------- 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir m_aLogger.log( LogLevel::FINER, STR_LOG_CLEAR_PARAMETERS ); 547*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 548*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir SDBThreadAttach t; 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir createStatement(t.pEnv); 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir static jmethodID mID(NULL); 555*cdf0e10cSrcweir callVoidMethod("clearParameters",mID); 556*cdf0e10cSrcweir } //t.pEnv 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir // ------------------------------------------------------------------------- 559*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 562*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 563*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir createStatement(t.pEnv); 566*cdf0e10cSrcweir static jmethodID mID(NULL); 567*cdf0e10cSrcweir callVoidMethod("clearBatch",mID); 568*cdf0e10cSrcweir } //t.pEnv 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir // ------------------------------------------------------------------------- 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 575*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 576*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir createStatement(t.pEnv); 579*cdf0e10cSrcweir static jmethodID mID(NULL); 580*cdf0e10cSrcweir callVoidMethod("addBatch",mID); 581*cdf0e10cSrcweir } //t.pEnv 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir // ------------------------------------------------------------------------- 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL java_sql_PreparedStatement::executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 588*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 589*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int32 > aSeq; 590*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 591*cdf0e10cSrcweir createStatement(t.pEnv); 592*cdf0e10cSrcweir static jmethodID mID(NULL); 593*cdf0e10cSrcweir jintArray out = (jintArray)callObjectMethod(t.pEnv,"executeBatch","()[I", mID); 594*cdf0e10cSrcweir if(out) 595*cdf0e10cSrcweir { 596*cdf0e10cSrcweir jboolean p = sal_False; 597*cdf0e10cSrcweir aSeq.realloc(t.pEnv->GetArrayLength(out)); 598*cdf0e10cSrcweir memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength()); 599*cdf0e10cSrcweir t.pEnv->DeleteLocalRef(out); 600*cdf0e10cSrcweir } 601*cdf0e10cSrcweir return aSeq; 602*cdf0e10cSrcweir } 603*cdf0e10cSrcweir // ------------------------------------------------------------------------- 604*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL java_sql_PreparedStatement::getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 607*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 608*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 609*cdf0e10cSrcweir createStatement(t.pEnv); 610*cdf0e10cSrcweir static jmethodID mID(NULL); 611*cdf0e10cSrcweir jobject out = callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/ResultSetMetaData;", mID); 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir return out==0 ? 0 : new java_sql_ResultSetMetaData( t.pEnv, out, m_aLogger,*m_pConnection ); 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 616*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::acquire() throw() 617*cdf0e10cSrcweir { 618*cdf0e10cSrcweir OStatement_BASE2::acquire(); 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 621*cdf0e10cSrcweir void SAL_CALL java_sql_PreparedStatement::release() throw() 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir OStatement_BASE2::release(); 624*cdf0e10cSrcweir } 625*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 626*cdf0e10cSrcweir void java_sql_PreparedStatement::createStatement(JNIEnv* _pEnv) 627*cdf0e10cSrcweir { 628*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 629*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir if( !object && _pEnv ){ 632*cdf0e10cSrcweir // temporaere Variable initialisieren 633*cdf0e10cSrcweir static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/PreparedStatement;"; 634*cdf0e10cSrcweir static const char * cMethodName = "prepareStatement"; 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir jvalue args[1]; 637*cdf0e10cSrcweir // Parameter konvertieren 638*cdf0e10cSrcweir args[0].l = convertwchar_tToJavaString(_pEnv,m_sSqlStatement); 639*cdf0e10cSrcweir // Java-Call absetzen 640*cdf0e10cSrcweir jobject out = NULL; 641*cdf0e10cSrcweir static jmethodID mID(NULL); 642*cdf0e10cSrcweir if ( !mID ) 643*cdf0e10cSrcweir mID = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature ); 644*cdf0e10cSrcweir if( mID ) 645*cdf0e10cSrcweir { 646*cdf0e10cSrcweir out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, args[0].l ,m_nResultSetType,m_nResultSetConcurrency); 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir else 649*cdf0e10cSrcweir { 650*cdf0e10cSrcweir static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/PreparedStatement;"; 651*cdf0e10cSrcweir static jmethodID mID2 = NULL; 652*cdf0e10cSrcweir if ( !mID2) 653*cdf0e10cSrcweir mID2 = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID,"Unknown method id!"); 654*cdf0e10cSrcweir if ( mID2 ) 655*cdf0e10cSrcweir out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, args[0].l ); 656*cdf0e10cSrcweir } 657*cdf0e10cSrcweir _pEnv->DeleteLocalRef((jstring)args[0].l); 658*cdf0e10cSrcweir ThrowLoggedSQLException( m_aLogger, _pEnv, *this ); 659*cdf0e10cSrcweir if ( out ) 660*cdf0e10cSrcweir object = _pEnv->NewGlobalRef( out ); 661*cdf0e10cSrcweir } //t.pEnv 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir 667