1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: callablestatement.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef _DBA_COREAPI_CALLABLESTATEMENT_HXX_
34 #include <callablestatement.hxx>
36 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
37 #include <com/sun/star/lang/DisposedException.hpp>
39 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
40 #include <cppuhelper/typeprovider.hxx>
42 #ifndef _COMPHELPER_PROPERTY_HXX_
43 #include <comphelper/property.hxx>
45 #ifndef _TOOLS_DEBUG_HXX //autogen
46 #include <tools/debug.hxx>
48 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
49 #include "dbastrings.hrc"
51 #include <rtl/logfile.hxx>
53 using namespace dbaccess
;
54 using namespace ::com::sun::star::sdbc
;
55 using namespace ::com::sun::star::sdbcx
;
56 using namespace ::com::sun::star::beans
;
57 using namespace ::com::sun::star::uno
;
58 using namespace ::com::sun::star::lang
;
59 using namespace ::cppu
;
60 using namespace ::osl
;
62 // com::sun::star::lang::XTypeProvider
63 //--------------------------------------------------------------------------
64 Sequence
< Type
> OCallableStatement::getTypes() throw (RuntimeException
)
66 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTypes" );
67 OTypeCollection
aTypes(::getCppuType( (const Reference
< XRow
> *)0 ),
68 ::getCppuType( (const Reference
< XOutParameters
> *)0 ),
69 OPreparedStatement::getTypes() );
71 return aTypes
.getTypes();
74 //--------------------------------------------------------------------------
75 Sequence
< sal_Int8
> OCallableStatement::getImplementationId() throw (RuntimeException
)
77 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getImplementationId" );
78 static OImplementationId
* pId
= 0;
81 MutexGuard
aGuard( Mutex::getGlobalMutex() );
84 static OImplementationId aId
;
88 return pId
->getImplementationId();
91 // com::sun::star::uno::XInterface
92 //--------------------------------------------------------------------------
93 Any
OCallableStatement::queryInterface( const Type
& rType
) throw (RuntimeException
)
95 //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::queryInterface" );
96 Any aIface
= OPreparedStatement::queryInterface( rType
);
97 if (!aIface
.hasValue())
98 aIface
= ::cppu::queryInterface(
100 static_cast< XRow
* >( this ),
101 static_cast< XOutParameters
* >( this ));
105 //--------------------------------------------------------------------------
106 void OCallableStatement::acquire() throw ()
108 OPreparedStatement::acquire();
111 //--------------------------------------------------------------------------
112 void OCallableStatement::release() throw ()
114 OPreparedStatement::release();
118 //------------------------------------------------------------------------------
119 rtl::OUString
OCallableStatement::getImplementationName( ) throw(RuntimeException
)
121 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getImplementationName" );
122 return rtl::OUString::createFromAscii("com.sun.star.sdb.OCallableStatement");
125 //------------------------------------------------------------------------------
126 Sequence
< ::rtl::OUString
> OCallableStatement::getSupportedServiceNames( ) throw (RuntimeException
)
128 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getSupportedServiceNames" );
129 Sequence
< ::rtl::OUString
> aSNS( 2 );
130 aSNS
.getArray()[0] = SERVICE_SDBC_CALLABLESTATEMENT
;
131 aSNS
.getArray()[1] = SERVICE_SDB_CALLABLESTATEMENT
;
136 //------------------------------------------------------------------------------
137 void SAL_CALL
OCallableStatement::registerOutParameter( sal_Int32 parameterIndex
, sal_Int32 sqlType
, const ::rtl::OUString
& typeName
) throw(SQLException
, RuntimeException
)
139 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::registerOutParameter" );
140 MutexGuard
aGuard(m_aMutex
);
142 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
145 Reference
< XOutParameters
>(m_xAggregateAsSet
, UNO_QUERY
)->registerOutParameter( parameterIndex
, sqlType
, typeName
);
148 //------------------------------------------------------------------------------
149 void SAL_CALL
OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex
, sal_Int32 sqlType
, sal_Int32 scale
) throw(SQLException
, RuntimeException
)
151 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::registerNumericOutParameter" );
152 MutexGuard
aGuard(m_aMutex
);
153 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
155 Reference
< XOutParameters
>(m_xAggregateAsSet
, UNO_QUERY
)->registerNumericOutParameter( parameterIndex
, sqlType
, scale
);
159 //------------------------------------------------------------------------------
160 sal_Bool SAL_CALL
OCallableStatement::wasNull( ) throw(SQLException
, RuntimeException
)
162 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::wasNull" );
163 MutexGuard
aGuard(m_aMutex
);
164 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
166 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->wasNull();
169 //------------------------------------------------------------------------------
170 ::rtl::OUString SAL_CALL
OCallableStatement::getString( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
172 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getString" );
173 MutexGuard
aGuard(m_aMutex
);
174 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
176 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getString( columnIndex
);
179 //------------------------------------------------------------------------------
180 sal_Bool SAL_CALL
OCallableStatement::getBoolean( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
182 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBoolean" );
183 MutexGuard
aGuard(m_aMutex
);
184 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
186 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getBoolean( columnIndex
);
189 //------------------------------------------------------------------------------
190 sal_Int8 SAL_CALL
OCallableStatement::getByte( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
192 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getByte" );
193 MutexGuard
aGuard(m_aMutex
);
194 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
196 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getByte( columnIndex
);
199 //------------------------------------------------------------------------------
200 sal_Int16 SAL_CALL
OCallableStatement::getShort( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
202 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getShort" );
203 MutexGuard
aGuard(m_aMutex
);
204 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
205 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getShort( columnIndex
);
208 //------------------------------------------------------------------------------
209 sal_Int32 SAL_CALL
OCallableStatement::getInt( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
211 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getInt" );
212 MutexGuard
aGuard(m_aMutex
);
213 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
214 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getInt( columnIndex
);
217 //------------------------------------------------------------------------------
218 sal_Int64 SAL_CALL
OCallableStatement::getLong( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
220 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getLong" );
221 MutexGuard
aGuard(m_aMutex
);
222 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
223 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getLong( columnIndex
);
226 //------------------------------------------------------------------------------
227 float SAL_CALL
OCallableStatement::getFloat( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
229 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getFloat" );
230 MutexGuard
aGuard(m_aMutex
);
231 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
232 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getFloat( columnIndex
);
235 //------------------------------------------------------------------------------
236 double SAL_CALL
OCallableStatement::getDouble( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
238 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getDouble" );
239 MutexGuard
aGuard(m_aMutex
);
240 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
241 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getDouble( columnIndex
);
244 //------------------------------------------------------------------------------
245 Sequence
< sal_Int8
> SAL_CALL
OCallableStatement::getBytes( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
247 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBytes" );
248 MutexGuard
aGuard(m_aMutex
);
249 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
250 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getBytes( columnIndex
);
253 //------------------------------------------------------------------------------
254 ::com::sun::star::util::Date SAL_CALL
OCallableStatement::getDate( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
256 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getDate" );
257 MutexGuard
aGuard(m_aMutex
);
258 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
259 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getDate( columnIndex
);
262 //------------------------------------------------------------------------------
263 ::com::sun::star::util::Time SAL_CALL
OCallableStatement::getTime( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
265 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTime" );
266 MutexGuard
aGuard(m_aMutex
);
267 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
268 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getTime( columnIndex
);
271 //------------------------------------------------------------------------------
272 ::com::sun::star::util::DateTime SAL_CALL
OCallableStatement::getTimestamp( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
274 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTimestamp" );
275 MutexGuard
aGuard(m_aMutex
);
276 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
278 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getTimestamp( columnIndex
);
281 //------------------------------------------------------------------------------
282 Reference
< ::com::sun::star::io::XInputStream
> SAL_CALL
OCallableStatement::getBinaryStream( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
284 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBinaryStream" );
285 MutexGuard
aGuard(m_aMutex
);
286 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
288 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getBinaryStream( columnIndex
);
291 //------------------------------------------------------------------------------
292 Reference
< ::com::sun::star::io::XInputStream
> SAL_CALL
OCallableStatement::getCharacterStream( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
294 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getCharacterStream" );
295 MutexGuard
aGuard(m_aMutex
);
296 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
298 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getCharacterStream( columnIndex
);
301 //------------------------------------------------------------------------------
302 Any SAL_CALL
OCallableStatement::getObject( sal_Int32 columnIndex
, const Reference
< ::com::sun::star::container::XNameAccess
>& typeMap
) throw(SQLException
, RuntimeException
)
304 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getObject" );
305 MutexGuard
aGuard(m_aMutex
);
306 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
308 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getObject( columnIndex
, typeMap
);
311 //------------------------------------------------------------------------------
312 Reference
< XRef
> SAL_CALL
OCallableStatement::getRef( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
314 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getRef" );
315 MutexGuard
aGuard(m_aMutex
);
316 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
317 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getRef( columnIndex
);
320 //------------------------------------------------------------------------------
321 Reference
< XBlob
> SAL_CALL
OCallableStatement::getBlob( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
323 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBlob" );
324 MutexGuard
aGuard(m_aMutex
);
325 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
326 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getBlob( columnIndex
);
329 //------------------------------------------------------------------------------
330 Reference
< XClob
> SAL_CALL
OCallableStatement::getClob( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
332 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getClob" );
333 MutexGuard
aGuard(m_aMutex
);
334 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
335 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getClob( columnIndex
);
338 //------------------------------------------------------------------------------
339 Reference
< XArray
> SAL_CALL
OCallableStatement::getArray( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
341 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getArray" );
342 MutexGuard
aGuard(m_aMutex
);
343 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
344 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getArray( columnIndex
);