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