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