1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_dbaccess.hxx"
26 #ifndef _DBA_COREAPI_CALLABLESTATEMENT_HXX_
27 #include <callablestatement.hxx>
28 #endif
29 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
30 #include <com/sun/star/lang/DisposedException.hpp>
31 #endif
32 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
33 #include <cppuhelper/typeprovider.hxx>
34 #endif
35 #ifndef _COMPHELPER_PROPERTY_HXX_
36 #include <comphelper/property.hxx>
37 #endif
38 #ifndef _TOOLS_DEBUG_HXX //autogen
39 #include <tools/debug.hxx>
40 #endif
41 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
42 #include "dbastrings.hrc"
43 #endif
44 #include <rtl/logfile.hxx>
45
46 using namespace dbaccess;
47 using namespace ::com::sun::star::sdbc;
48 using namespace ::com::sun::star::sdbcx;
49 using namespace ::com::sun::star::beans;
50 using namespace ::com::sun::star::uno;
51 using namespace ::com::sun::star::lang;
52 using namespace ::cppu;
53 using namespace ::osl;
54
55 // com::sun::star::lang::XTypeProvider
56 //--------------------------------------------------------------------------
getTypes()57 Sequence< Type > OCallableStatement::getTypes() throw (RuntimeException)
58 {
59 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTypes" );
60 OTypeCollection aTypes(::getCppuType( (const Reference< XRow > *)0 ),
61 ::getCppuType( (const Reference< XOutParameters > *)0 ),
62 OPreparedStatement::getTypes() );
63
64 return aTypes.getTypes();
65 }
66
67 //--------------------------------------------------------------------------
getImplementationId()68 Sequence< sal_Int8 > OCallableStatement::getImplementationId() throw (RuntimeException)
69 {
70 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getImplementationId" );
71 static OImplementationId * pId = 0;
72 if (! pId)
73 {
74 MutexGuard aGuard( Mutex::getGlobalMutex() );
75 if (! pId)
76 {
77 static OImplementationId aId;
78 pId = &aId;
79 }
80 }
81 return pId->getImplementationId();
82 }
83
84 // com::sun::star::uno::XInterface
85 //--------------------------------------------------------------------------
queryInterface(const Type & rType)86 Any OCallableStatement::queryInterface( const Type & rType ) throw (RuntimeException)
87 {
88 //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::queryInterface" );
89 Any aIface = OPreparedStatement::queryInterface( rType );
90 if (!aIface.hasValue())
91 aIface = ::cppu::queryInterface(
92 rType,
93 static_cast< XRow * >( this ),
94 static_cast< XOutParameters * >( this ));
95 return aIface;
96 }
97
98 //--------------------------------------------------------------------------
acquire()99 void OCallableStatement::acquire() throw ()
100 {
101 OPreparedStatement::acquire();
102 }
103
104 //--------------------------------------------------------------------------
release()105 void OCallableStatement::release() throw ()
106 {
107 OPreparedStatement::release();
108 }
109
110 // XServiceInfo
111 //------------------------------------------------------------------------------
getImplementationName()112 rtl::OUString OCallableStatement::getImplementationName( ) throw(RuntimeException)
113 {
114 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getImplementationName" );
115 return rtl::OUString::createFromAscii("com.sun.star.sdb.OCallableStatement");
116 }
117
118 //------------------------------------------------------------------------------
getSupportedServiceNames()119 Sequence< ::rtl::OUString > OCallableStatement::getSupportedServiceNames( ) throw (RuntimeException)
120 {
121 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getSupportedServiceNames" );
122 Sequence< ::rtl::OUString > aSNS( 2 );
123 aSNS.getArray()[0] = SERVICE_SDBC_CALLABLESTATEMENT;
124 aSNS.getArray()[1] = SERVICE_SDB_CALLABLESTATEMENT;
125 return aSNS;
126 }
127
128 // XOutParameters
129 //------------------------------------------------------------------------------
registerOutParameter(sal_Int32 parameterIndex,sal_Int32 sqlType,const::rtl::OUString & typeName)130 void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(SQLException, RuntimeException)
131 {
132 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::registerOutParameter" );
133 MutexGuard aGuard(m_aMutex);
134
135 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
136
137
138 Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerOutParameter( parameterIndex, sqlType, typeName );
139 }
140
141 //------------------------------------------------------------------------------
registerNumericOutParameter(sal_Int32 parameterIndex,sal_Int32 sqlType,sal_Int32 scale)142 void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
143 {
144 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::registerNumericOutParameter" );
145 MutexGuard aGuard(m_aMutex);
146 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
147
148 Reference< XOutParameters >(m_xAggregateAsSet, UNO_QUERY)->registerNumericOutParameter( parameterIndex, sqlType, scale );
149 }
150
151 // XRow
152 //------------------------------------------------------------------------------
wasNull()153 sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException)
154 {
155 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::wasNull" );
156 MutexGuard aGuard(m_aMutex);
157 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
158
159 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->wasNull();
160 }
161
162 //------------------------------------------------------------------------------
getString(sal_Int32 columnIndex)163 ::rtl::OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
164 {
165 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getString" );
166 MutexGuard aGuard(m_aMutex);
167 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
168
169 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getString( columnIndex );
170 }
171
172 //------------------------------------------------------------------------------
getBoolean(sal_Int32 columnIndex)173 sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
174 {
175 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBoolean" );
176 MutexGuard aGuard(m_aMutex);
177 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
178
179 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBoolean( columnIndex );
180 }
181
182 //------------------------------------------------------------------------------
getByte(sal_Int32 columnIndex)183 sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
184 {
185 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getByte" );
186 MutexGuard aGuard(m_aMutex);
187 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
188
189 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getByte( columnIndex );
190 }
191
192 //------------------------------------------------------------------------------
getShort(sal_Int32 columnIndex)193 sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
194 {
195 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getShort" );
196 MutexGuard aGuard(m_aMutex);
197 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
198 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getShort( columnIndex );
199 }
200
201 //------------------------------------------------------------------------------
getInt(sal_Int32 columnIndex)202 sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
203 {
204 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getInt" );
205 MutexGuard aGuard(m_aMutex);
206 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
207 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getInt( columnIndex );
208 }
209
210 //------------------------------------------------------------------------------
getLong(sal_Int32 columnIndex)211 sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
212 {
213 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getLong" );
214 MutexGuard aGuard(m_aMutex);
215 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
216 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getLong( columnIndex );
217 }
218
219 //------------------------------------------------------------------------------
getFloat(sal_Int32 columnIndex)220 float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
221 {
222 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getFloat" );
223 MutexGuard aGuard(m_aMutex);
224 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
225 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getFloat( columnIndex );
226 }
227
228 //------------------------------------------------------------------------------
getDouble(sal_Int32 columnIndex)229 double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
230 {
231 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getDouble" );
232 MutexGuard aGuard(m_aMutex);
233 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
234 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDouble( columnIndex );
235 }
236
237 //------------------------------------------------------------------------------
getBytes(sal_Int32 columnIndex)238 Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
239 {
240 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBytes" );
241 MutexGuard aGuard(m_aMutex);
242 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
243 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBytes( columnIndex );
244 }
245
246 //------------------------------------------------------------------------------
getDate(sal_Int32 columnIndex)247 ::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
248 {
249 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getDate" );
250 MutexGuard aGuard(m_aMutex);
251 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
252 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getDate( columnIndex );
253 }
254
255 //------------------------------------------------------------------------------
getTime(sal_Int32 columnIndex)256 ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
257 {
258 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTime" );
259 MutexGuard aGuard(m_aMutex);
260 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
261 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTime( columnIndex );
262 }
263
264 //------------------------------------------------------------------------------
getTimestamp(sal_Int32 columnIndex)265 ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
266 {
267 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTimestamp" );
268 MutexGuard aGuard(m_aMutex);
269 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
270
271 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getTimestamp( columnIndex );
272 }
273
274 //------------------------------------------------------------------------------
getBinaryStream(sal_Int32 columnIndex)275 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
276 {
277 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBinaryStream" );
278 MutexGuard aGuard(m_aMutex);
279 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
280
281 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBinaryStream( columnIndex );
282 }
283
284 //------------------------------------------------------------------------------
getCharacterStream(sal_Int32 columnIndex)285 Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
286 {
287 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getCharacterStream" );
288 MutexGuard aGuard(m_aMutex);
289 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
290
291 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getCharacterStream( columnIndex );
292 }
293
294 //------------------------------------------------------------------------------
getObject(sal_Int32 columnIndex,const Reference<::com::sun::star::container::XNameAccess> & typeMap)295 Any SAL_CALL OCallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
296 {
297 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getObject" );
298 MutexGuard aGuard(m_aMutex);
299 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
300
301 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getObject( columnIndex, typeMap );
302 }
303
304 //------------------------------------------------------------------------------
getRef(sal_Int32 columnIndex)305 Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
306 {
307 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getRef" );
308 MutexGuard aGuard(m_aMutex);
309 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
310 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getRef( columnIndex );
311 }
312
313 //------------------------------------------------------------------------------
getBlob(sal_Int32 columnIndex)314 Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
315 {
316 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBlob" );
317 MutexGuard aGuard(m_aMutex);
318 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
319 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getBlob( columnIndex );
320 }
321
322 //------------------------------------------------------------------------------
getClob(sal_Int32 columnIndex)323 Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
324 {
325 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getClob" );
326 MutexGuard aGuard(m_aMutex);
327 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
328 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getClob( columnIndex );
329 }
330
331 //------------------------------------------------------------------------------
getArray(sal_Int32 columnIndex)332 Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
333 {
334 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getArray" );
335 MutexGuard aGuard(m_aMutex);
336 ::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
337 return Reference< XRow >(m_xAggregateAsSet, UNO_QUERY)->getArray( columnIndex );
338 }
339
340
341