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/CallableStatement.hxx" 31*cdf0e10cSrcweir #include "java/tools.hxx" 32*cdf0e10cSrcweir #include "java/sql/Array.hxx" 33*cdf0e10cSrcweir #include "java/sql/Clob.hxx" 34*cdf0e10cSrcweir #include "java/sql/Blob.hxx" 35*cdf0e10cSrcweir #include "java/sql/Connection.hxx" 36*cdf0e10cSrcweir #include "java/sql/Ref.hxx" 37*cdf0e10cSrcweir #include "java/sql/Timestamp.hxx" 38*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 39*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <string.h> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir using namespace connectivity; 44*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 45*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 46*cdf0e10cSrcweir // using namespace ::com::sun::star::sdbcx; 47*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 48*cdf0e10cSrcweir using namespace ::com::sun::star::container; 49*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(java_sql_CallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement"); 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir //************************************************************** 55*cdf0e10cSrcweir //************ Class: java.sql.CallableStatement 56*cdf0e10cSrcweir //************************************************************** 57*cdf0e10cSrcweir java_sql_CallableStatement::java_sql_CallableStatement( JNIEnv * pEnv, java_sql_Connection& _rCon,const ::rtl::OUString& sql ) 58*cdf0e10cSrcweir : java_sql_PreparedStatement( pEnv, _rCon, sql ) 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 62*cdf0e10cSrcweir java_sql_CallableStatement::~java_sql_CallableStatement() 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir Any SAL_CALL java_sql_CallableStatement::queryInterface( const Type & rType ) throw(RuntimeException) 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir Any aRet = java_sql_PreparedStatement::queryInterface(rType); 70*cdf0e10cSrcweir return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< starsdbc::XRow*>(this),static_cast< starsdbc::XOutParameters*>(this)); 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir // ------------------------------------------------------------------------- 73*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_CallableStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< starsdbc::XRow > *)0 ), 76*cdf0e10cSrcweir ::getCppuType( (const ::com::sun::star::uno::Reference< starsdbc::XOutParameters > *)0 )); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir return ::comphelper::concatSequences(aTypes.getTypes(),java_sql_PreparedStatement::getTypes()); 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir // ------------------------------------------------------------------------- 81*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_CallableStatement::wasNull( ) throw(starsdbc::SQLException, RuntimeException) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir static jmethodID mID(NULL); 84*cdf0e10cSrcweir return callBooleanMethod( "wasNull", mID ); 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir sal_Bool SAL_CALL java_sql_CallableStatement::getBoolean( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 88*cdf0e10cSrcweir { 89*cdf0e10cSrcweir static jmethodID mID(NULL); 90*cdf0e10cSrcweir return callBooleanMethodWithIntArg( "getBoolean", mID,columnIndex ); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir sal_Int8 SAL_CALL java_sql_CallableStatement::getByte( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 95*cdf0e10cSrcweir createStatement(t.pEnv); 96*cdf0e10cSrcweir static jmethodID mID(NULL); 97*cdf0e10cSrcweir jbyte (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallByteMethod; 98*cdf0e10cSrcweir return callMethodWithIntArg<jbyte>(pCallMethod,"getByte","(I)B",mID,columnIndex); 99*cdf0e10cSrcweir } 100*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL java_sql_CallableStatement::getBytes( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 103*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 104*cdf0e10cSrcweir Sequence< sal_Int8 > aSeq; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 107*cdf0e10cSrcweir createStatement(t.pEnv); 108*cdf0e10cSrcweir static jmethodID mID(NULL); 109*cdf0e10cSrcweir jbyteArray out = (jbyteArray)callObjectMethodWithIntArg(t.pEnv,"getBytes","(I)[B", mID, columnIndex); 110*cdf0e10cSrcweir if (out) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir jboolean p = sal_False; 113*cdf0e10cSrcweir aSeq.realloc(t.pEnv->GetArrayLength(out)); 114*cdf0e10cSrcweir memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength()); 115*cdf0e10cSrcweir t.pEnv->DeleteLocalRef(out); 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir return aSeq; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir ::com::sun::star::util::Date SAL_CALL java_sql_CallableStatement::getDate( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 122*cdf0e10cSrcweir createStatement(t.pEnv); 123*cdf0e10cSrcweir static jmethodID mID(NULL); 124*cdf0e10cSrcweir jobject out = callObjectMethodWithIntArg(t.pEnv,"getDate","(I)Ljava/sql/Date;", mID, columnIndex); 125*cdf0e10cSrcweir return out ? static_cast <com::sun::star::util::Date>(java_sql_Date( t.pEnv, out )) : ::com::sun::star::util::Date(); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir double SAL_CALL java_sql_CallableStatement::getDouble( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 130*cdf0e10cSrcweir createStatement(t.pEnv); 131*cdf0e10cSrcweir static jmethodID mID(NULL); 132*cdf0e10cSrcweir double (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallDoubleMethod; 133*cdf0e10cSrcweir return callMethodWithIntArg<double>(pCallMethod,"getDouble","(I)D",mID,columnIndex); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir float SAL_CALL java_sql_CallableStatement::getFloat( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 139*cdf0e10cSrcweir createStatement(t.pEnv); 140*cdf0e10cSrcweir static jmethodID mID(NULL); 141*cdf0e10cSrcweir jfloat (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallFloatMethod; 142*cdf0e10cSrcweir return callMethodWithIntArg<jfloat>(pCallMethod,"getFloat","(I)F",mID,columnIndex); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir sal_Int32 SAL_CALL java_sql_CallableStatement::getInt( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 148*cdf0e10cSrcweir createStatement(t.pEnv); 149*cdf0e10cSrcweir static jmethodID mID(NULL); 150*cdf0e10cSrcweir return callIntMethodWithIntArg("getInt",mID,columnIndex); 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir sal_Int64 SAL_CALL java_sql_CallableStatement::getLong( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 156*cdf0e10cSrcweir createStatement(t.pEnv); 157*cdf0e10cSrcweir static jmethodID mID(NULL); 158*cdf0e10cSrcweir jlong (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallLongMethod; 159*cdf0e10cSrcweir return callMethodWithIntArg<jlong>(pCallMethod,"getLong","(I)J",mID,columnIndex); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir Any SAL_CALL java_sql_CallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(starsdbc::SQLException, RuntimeException) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 165*cdf0e10cSrcweir createStatement(t.pEnv); 166*cdf0e10cSrcweir static jmethodID mID(NULL); 167*cdf0e10cSrcweir /*jobject out = */callObjectMethodWithIntArg(t.pEnv,"getObject","(I)Ljava/lang/Object;", mID, columnIndex); 168*cdf0e10cSrcweir // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! 169*cdf0e10cSrcweir return Any(); //out==0 ? 0 : new java_lang_Object( t.pEnv, out ); 170*cdf0e10cSrcweir } 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir sal_Int16 SAL_CALL java_sql_CallableStatement::getShort( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 175*cdf0e10cSrcweir createStatement(t.pEnv); 176*cdf0e10cSrcweir static jmethodID mID(NULL); 177*cdf0e10cSrcweir jshort (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallShortMethod; 178*cdf0e10cSrcweir return callMethodWithIntArg<jshort>(pCallMethod,"getShort","(I)S",mID,columnIndex); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir ::rtl::OUString SAL_CALL java_sql_CallableStatement::getString( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 184*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 185*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 186*cdf0e10cSrcweir createStatement(t.pEnv); 187*cdf0e10cSrcweir static jmethodID mID(NULL); 188*cdf0e10cSrcweir return callStringMethodWithIntArg("getString",mID,columnIndex); 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir ::com::sun::star::util::Time SAL_CALL java_sql_CallableStatement::getTime( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 194*cdf0e10cSrcweir createStatement(t.pEnv); 195*cdf0e10cSrcweir static jmethodID mID(NULL); 196*cdf0e10cSrcweir jobject out = callObjectMethodWithIntArg(t.pEnv,"getTime","(I)Ljava/sql/Time;", mID, columnIndex); 197*cdf0e10cSrcweir // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! 198*cdf0e10cSrcweir return out ? static_cast <com::sun::star::util::Time> (java_sql_Time( t.pEnv, out )) : ::com::sun::star::util::Time(); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir ::com::sun::star::util::DateTime SAL_CALL java_sql_CallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 204*cdf0e10cSrcweir createStatement(t.pEnv); 205*cdf0e10cSrcweir static jmethodID mID(NULL); 206*cdf0e10cSrcweir jobject out = callObjectMethodWithIntArg(t.pEnv,"getTimestamp","(I)Ljava/sql/Timestamp;", mID, columnIndex); 207*cdf0e10cSrcweir // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! 208*cdf0e10cSrcweir return out ? static_cast <com::sun::star::util::DateTime> (java_sql_Timestamp( t.pEnv, out )) : ::com::sun::star::util::DateTime(); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir void SAL_CALL java_sql_CallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(starsdbc::SQLException, RuntimeException) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 214*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 215*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir createStatement(t.pEnv); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir // temporaere Variable initialisieren 221*cdf0e10cSrcweir static const char * cSignature = "(IILjava/lang/String;)V"; 222*cdf0e10cSrcweir static const char * cMethodName = "registerOutParameter"; 223*cdf0e10cSrcweir // Java-Call absetzen 224*cdf0e10cSrcweir static jmethodID mID(NULL); 225*cdf0e10cSrcweir obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 226*cdf0e10cSrcweir // Parameter konvertieren 227*cdf0e10cSrcweir jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,typeName)); 228*cdf0e10cSrcweir t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str.get()); 229*cdf0e10cSrcweir ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir void SAL_CALL java_sql_CallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 235*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 236*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir createStatement(t.pEnv); 240*cdf0e10cSrcweir // temporaere Variable initialisieren 241*cdf0e10cSrcweir static const char * cSignature = "(III)V"; 242*cdf0e10cSrcweir static const char * cMethodName = "registerOutParameter"; 243*cdf0e10cSrcweir // Java-Call absetzen 244*cdf0e10cSrcweir static jmethodID mID(NULL); 245*cdf0e10cSrcweir obtainMethodId(t.pEnv, cMethodName,cSignature, mID); 246*cdf0e10cSrcweir t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,scale); 247*cdf0e10cSrcweir ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir jclass java_sql_CallableStatement::theClass = 0; 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir jclass java_sql_CallableStatement::getMyClass() const 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir // die Klasse muss nur einmal geholt werden, daher statisch 256*cdf0e10cSrcweir if( !theClass ) 257*cdf0e10cSrcweir theClass = findMyClass("java/sql/CallableStatement"); 258*cdf0e10cSrcweir return theClass; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_CallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir Reference< starsdbc::XBlob > xBlob = getBlob(columnIndex); 264*cdf0e10cSrcweir return xBlob.is() ? xBlob->getBinaryStream() : Reference< ::com::sun::star::io::XInputStream >(); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_CallableStatement::getCharacterStream( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir Reference< starsdbc::XClob > xClob = getClob(columnIndex); 269*cdf0e10cSrcweir return xClob.is() ? xClob->getCharacterStream() : Reference< ::com::sun::star::io::XInputStream >(); 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir Reference< starsdbc::XArray > SAL_CALL java_sql_CallableStatement::getArray( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 275*cdf0e10cSrcweir createStatement(t.pEnv); 276*cdf0e10cSrcweir static jmethodID mID(NULL); 277*cdf0e10cSrcweir jobject out = callObjectMethodWithIntArg(t.pEnv,"getArray","(I)Ljava/sql/Array;", mID, columnIndex); 278*cdf0e10cSrcweir // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! 279*cdf0e10cSrcweir return out==0 ? 0 : new java_sql_Array( t.pEnv, out ); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir Reference< starsdbc::XClob > SAL_CALL java_sql_CallableStatement::getClob( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 285*cdf0e10cSrcweir createStatement(t.pEnv); 286*cdf0e10cSrcweir static jmethodID mID(NULL); 287*cdf0e10cSrcweir jobject out = callObjectMethodWithIntArg(t.pEnv,"getClob","(I)Ljava/sql/Clob;", mID, columnIndex); 288*cdf0e10cSrcweir // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! 289*cdf0e10cSrcweir return out==0 ? 0 : new java_sql_Clob( t.pEnv, out ); 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir Reference< starsdbc::XBlob > SAL_CALL java_sql_CallableStatement::getBlob( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 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 jobject out = callObjectMethodWithIntArg(t.pEnv,"getBlob","(I)Ljava/sql/Blob;", mID, columnIndex); 297*cdf0e10cSrcweir // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! 298*cdf0e10cSrcweir return out==0 ? 0 : new java_sql_Blob( t.pEnv, out ); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir Reference< starsdbc::XRef > SAL_CALL java_sql_CallableStatement::getRef( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 304*cdf0e10cSrcweir createStatement(t.pEnv); 305*cdf0e10cSrcweir static jmethodID mID(NULL); 306*cdf0e10cSrcweir jobject out = callObjectMethodWithIntArg(t.pEnv,"getRef","(I)Ljava/sql/Ref;", mID, columnIndex); 307*cdf0e10cSrcweir // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! 308*cdf0e10cSrcweir return out==0 ? 0 : new java_sql_Ref( t.pEnv, out ); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 311*cdf0e10cSrcweir void SAL_CALL java_sql_CallableStatement::acquire() throw() 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir java_sql_PreparedStatement::acquire(); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 316*cdf0e10cSrcweir void SAL_CALL java_sql_CallableStatement::release() throw() 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir java_sql_PreparedStatement::release(); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 321*cdf0e10cSrcweir void java_sql_CallableStatement::createStatement(JNIEnv* /*_pEnv*/) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 324*cdf0e10cSrcweir checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed); 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); 328*cdf0e10cSrcweir if( t.pEnv && !object ){ 329*cdf0e10cSrcweir // temporaere Variable initialisieren 330*cdf0e10cSrcweir static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/CallableStatement;"; 331*cdf0e10cSrcweir static const char * cMethodName = "prepareCall"; 332*cdf0e10cSrcweir // Java-Call absetzen 333*cdf0e10cSrcweir jobject out = NULL; 334*cdf0e10cSrcweir // Parameter konvertieren 335*cdf0e10cSrcweir jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,m_sSqlStatement)); 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir static jmethodID mID(NULL); 338*cdf0e10cSrcweir if ( !mID ) 339*cdf0e10cSrcweir mID = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature ); 340*cdf0e10cSrcweir if( mID ){ 341*cdf0e10cSrcweir out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str.get() ,m_nResultSetType,m_nResultSetConcurrency); 342*cdf0e10cSrcweir } //mID 343*cdf0e10cSrcweir else 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/CallableStatement;"; 346*cdf0e10cSrcweir static jmethodID mID2 = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,"Unknown method id!"); 347*cdf0e10cSrcweir if( mID2 ){ 348*cdf0e10cSrcweir out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, str.get() ); 349*cdf0e10cSrcweir } //mID 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir if ( out ) 354*cdf0e10cSrcweir object = t.pEnv->NewGlobalRef( out ); 355*cdf0e10cSrcweir } //t.pEnv 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir 360