1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <callablestatement.hxx>
21 #include <com/sun/star/lang/DisposedException.hpp>
22 #include <cppuhelper/typeprovider.hxx>
23 #include <comphelper/property.hxx>
24 #include "dbastrings.hrc"
25 #include <rtl/logfile.hxx>
27 using namespace dbaccess
;
28 using namespace ::com::sun::star::sdbc
;
29 using namespace ::com::sun::star::sdbcx
;
30 using namespace ::com::sun::star::beans
;
31 using namespace ::com::sun::star::uno
;
32 using namespace ::com::sun::star::lang
;
33 using namespace ::cppu
;
34 using namespace ::osl
;
36 // com::sun::star::lang::XTypeProvider
37 Sequence
< Type
> OCallableStatement::getTypes() throw (RuntimeException
)
39 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTypes" );
40 OTypeCollection
aTypes(::getCppuType( (const Reference
< XRow
> *)0 ),
41 ::getCppuType( (const Reference
< XOutParameters
> *)0 ),
42 OPreparedStatement::getTypes() );
44 return aTypes
.getTypes();
47 Sequence
< sal_Int8
> OCallableStatement::getImplementationId() throw (RuntimeException
)
49 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getImplementationId" );
50 static OImplementationId
* pId
= 0;
53 MutexGuard
aGuard( Mutex::getGlobalMutex() );
56 static OImplementationId aId
;
60 return pId
->getImplementationId();
63 // com::sun::star::uno::XInterface
64 Any
OCallableStatement::queryInterface( const Type
& rType
) throw (RuntimeException
)
66 //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::queryInterface" );
67 Any aIface
= OPreparedStatement::queryInterface( rType
);
68 if (!aIface
.hasValue())
69 aIface
= ::cppu::queryInterface(
71 static_cast< XRow
* >( this ),
72 static_cast< XOutParameters
* >( this ));
76 void OCallableStatement::acquire() throw ()
78 OPreparedStatement::acquire();
81 void OCallableStatement::release() throw ()
83 OPreparedStatement::release();
87 rtl::OUString
OCallableStatement::getImplementationName( ) throw(RuntimeException
)
89 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getImplementationName" );
90 return rtl::OUString("com.sun.star.sdb.OCallableStatement");
93 Sequence
< ::rtl::OUString
> OCallableStatement::getSupportedServiceNames( ) throw (RuntimeException
)
95 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getSupportedServiceNames" );
96 Sequence
< ::rtl::OUString
> aSNS( 2 );
97 aSNS
.getArray()[0] = SERVICE_SDBC_CALLABLESTATEMENT
;
98 aSNS
.getArray()[1] = SERVICE_SDB_CALLABLESTATEMENT
;
103 void SAL_CALL
OCallableStatement::registerOutParameter( sal_Int32 parameterIndex
, sal_Int32 sqlType
, const ::rtl::OUString
& typeName
) throw(SQLException
, RuntimeException
)
105 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::registerOutParameter" );
106 MutexGuard
aGuard(m_aMutex
);
108 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
110 Reference
< XOutParameters
>(m_xAggregateAsSet
, UNO_QUERY
)->registerOutParameter( parameterIndex
, sqlType
, typeName
);
113 void SAL_CALL
OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex
, sal_Int32 sqlType
, sal_Int32 scale
) throw(SQLException
, RuntimeException
)
115 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::registerNumericOutParameter" );
116 MutexGuard
aGuard(m_aMutex
);
117 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
119 Reference
< XOutParameters
>(m_xAggregateAsSet
, UNO_QUERY
)->registerNumericOutParameter( parameterIndex
, sqlType
, scale
);
123 sal_Bool SAL_CALL
OCallableStatement::wasNull( ) throw(SQLException
, RuntimeException
)
125 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::wasNull" );
126 MutexGuard
aGuard(m_aMutex
);
127 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
129 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->wasNull();
132 ::rtl::OUString SAL_CALL
OCallableStatement::getString( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
134 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getString" );
135 MutexGuard
aGuard(m_aMutex
);
136 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
138 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getString( columnIndex
);
141 sal_Bool SAL_CALL
OCallableStatement::getBoolean( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
143 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBoolean" );
144 MutexGuard
aGuard(m_aMutex
);
145 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
147 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getBoolean( columnIndex
);
150 sal_Int8 SAL_CALL
OCallableStatement::getByte( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
152 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getByte" );
153 MutexGuard
aGuard(m_aMutex
);
154 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
156 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getByte( columnIndex
);
159 sal_Int16 SAL_CALL
OCallableStatement::getShort( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
161 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getShort" );
162 MutexGuard
aGuard(m_aMutex
);
163 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
164 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getShort( columnIndex
);
167 sal_Int32 SAL_CALL
OCallableStatement::getInt( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
169 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getInt" );
170 MutexGuard
aGuard(m_aMutex
);
171 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
172 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getInt( columnIndex
);
175 sal_Int64 SAL_CALL
OCallableStatement::getLong( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
177 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getLong" );
178 MutexGuard
aGuard(m_aMutex
);
179 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
180 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getLong( columnIndex
);
183 float SAL_CALL
OCallableStatement::getFloat( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
185 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getFloat" );
186 MutexGuard
aGuard(m_aMutex
);
187 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
188 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getFloat( columnIndex
);
191 double SAL_CALL
OCallableStatement::getDouble( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
193 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getDouble" );
194 MutexGuard
aGuard(m_aMutex
);
195 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
196 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getDouble( columnIndex
);
199 Sequence
< sal_Int8
> SAL_CALL
OCallableStatement::getBytes( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
201 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBytes" );
202 MutexGuard
aGuard(m_aMutex
);
203 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
204 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getBytes( columnIndex
);
207 ::com::sun::star::util::Date SAL_CALL
OCallableStatement::getDate( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
209 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getDate" );
210 MutexGuard
aGuard(m_aMutex
);
211 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
212 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getDate( columnIndex
);
215 ::com::sun::star::util::Time SAL_CALL
OCallableStatement::getTime( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
217 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTime" );
218 MutexGuard
aGuard(m_aMutex
);
219 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
220 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getTime( columnIndex
);
223 ::com::sun::star::util::DateTime SAL_CALL
OCallableStatement::getTimestamp( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
225 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getTimestamp" );
226 MutexGuard
aGuard(m_aMutex
);
227 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
229 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getTimestamp( columnIndex
);
232 Reference
< ::com::sun::star::io::XInputStream
> SAL_CALL
OCallableStatement::getBinaryStream( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
234 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBinaryStream" );
235 MutexGuard
aGuard(m_aMutex
);
236 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
238 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getBinaryStream( columnIndex
);
241 Reference
< ::com::sun::star::io::XInputStream
> SAL_CALL
OCallableStatement::getCharacterStream( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
243 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getCharacterStream" );
244 MutexGuard
aGuard(m_aMutex
);
245 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
247 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getCharacterStream( columnIndex
);
250 Any SAL_CALL
OCallableStatement::getObject( sal_Int32 columnIndex
, const Reference
< ::com::sun::star::container::XNameAccess
>& typeMap
) throw(SQLException
, RuntimeException
)
252 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getObject" );
253 MutexGuard
aGuard(m_aMutex
);
254 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
256 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getObject( columnIndex
, typeMap
);
259 Reference
< XRef
> SAL_CALL
OCallableStatement::getRef( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
261 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getRef" );
262 MutexGuard
aGuard(m_aMutex
);
263 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
264 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getRef( columnIndex
);
267 Reference
< XBlob
> SAL_CALL
OCallableStatement::getBlob( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
269 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getBlob" );
270 MutexGuard
aGuard(m_aMutex
);
271 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
272 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getBlob( columnIndex
);
275 Reference
< XClob
> SAL_CALL
OCallableStatement::getClob( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
277 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getClob" );
278 MutexGuard
aGuard(m_aMutex
);
279 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
280 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getClob( columnIndex
);
283 Reference
< XArray
> SAL_CALL
OCallableStatement::getArray( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
285 RTL_LOGFILE_CONTEXT_AUTHOR( aLogger
, "dbaccess", "Ocke.Janssen@sun.com", "OCallableStatement::getArray" );
286 MutexGuard
aGuard(m_aMutex
);
287 ::connectivity::checkDisposed(OComponentHelper::rBHelper
.bDisposed
);
288 return Reference
< XRow
>(m_xAggregateAsSet
, UNO_QUERY
)->getArray( columnIndex
);
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */