Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <resultset.hxx>
21 : #include "dbastrings.hrc"
22 : #include "apitools.hxx"
23 : #include <com/sun/star/lang/DisposedException.hpp>
24 : #include <com/sun/star/sdbc/ResultSetType.hpp>
25 : #include <cppuhelper/supportsservice.hxx>
26 : #include <cppuhelper/typeprovider.hxx>
27 : #include <comphelper/property.hxx>
28 : #include <comphelper/sequence.hxx>
29 : #include <comphelper/types.hxx>
30 : #include <tools/debug.hxx>
31 : #include <tools/diagnose_ex.h>
32 : #include <datacolumn.hxx>
33 : #include <com/sun/star/beans/PropertyAttribute.hpp>
34 : #include <connectivity/dbexception.hxx>
35 : #include <connectivity/dbtools.hxx>
36 : #include <cppuhelper/exc_hlp.hxx>
37 : #include <osl/thread.h>
38 :
39 :
40 : using namespace ::com::sun::star::sdbc;
41 : using namespace ::com::sun::star::sdbcx;
42 : using namespace ::com::sun::star::beans;
43 : using namespace ::com::sun::star::uno;
44 : using namespace ::com::sun::star::lang;
45 : using namespace ::com::sun::star::container;
46 : using namespace ::cppu;
47 : using namespace ::osl;
48 : using namespace dbaccess;
49 : using namespace dbtools;
50 :
51 :
52 54 : OResultSet::OResultSet(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _xResultSet,
53 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xStatement,
54 : bool _bCaseSensitive)
55 : :OResultSetBase(m_aMutex)
56 : ,OPropertySetHelper(OResultSetBase::rBHelper)
57 : ,m_xDelegatorResultSet(_xResultSet)
58 : ,m_aWarnings( Reference< XWarningsSupplier >( _xResultSet, UNO_QUERY ) )
59 : ,m_nResultSetType(0)
60 : ,m_nResultSetConcurrency(0)
61 54 : ,m_bIsBookmarkable(false)
62 : {
63 54 : m_pColumns = new OColumns(*this, m_aMutex, _bCaseSensitive, ::std::vector< OUString>(), NULL,NULL);
64 :
65 : try
66 : {
67 54 : m_aStatement = _xStatement;
68 54 : m_xDelegatorResultSetUpdate.set(m_xDelegatorResultSet, css::uno::UNO_QUERY);
69 54 : m_xDelegatorRow.set(m_xDelegatorResultSet, css::uno::UNO_QUERY);
70 54 : m_xDelegatorRowUpdate.set(m_xDelegatorResultSet, css::uno::UNO_QUERY);
71 :
72 54 : Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
73 54 : xSet->getPropertyValue(PROPERTY_RESULTSETTYPE) >>= m_nResultSetType;
74 54 : xSet->getPropertyValue(PROPERTY_RESULTSETCONCURRENCY) >>= m_nResultSetConcurrency;
75 :
76 : // test for Bookmarks
77 54 : if (ResultSetType::FORWARD_ONLY != m_nResultSetType)
78 : {
79 46 : Reference <XPropertySetInfo > xInfo(xSet->getPropertySetInfo());
80 46 : if (xInfo->hasPropertyByName(PROPERTY_ISBOOKMARKABLE))
81 : {
82 46 : m_bIsBookmarkable = ::comphelper::getBOOL(xSet->getPropertyValue(PROPERTY_ISBOOKMARKABLE));
83 : OSL_ENSURE( !m_bIsBookmarkable || Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is(),
84 : "OResultSet::OResultSet: aggregate is inconsistent in it's bookmarkable attribute!" );
85 46 : m_bIsBookmarkable = m_bIsBookmarkable && Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY).is();
86 46 : }
87 54 : }
88 : }
89 0 : catch (const Exception&)
90 : {
91 : }
92 54 : }
93 :
94 162 : OResultSet::~OResultSet()
95 : {
96 54 : m_pColumns->acquire();
97 54 : m_pColumns->disposing();
98 54 : delete m_pColumns;
99 :
100 108 : }
101 :
102 : // com::sun::star::lang::XTypeProvider
103 12 : Sequence< Type > OResultSet::getTypes() throw (RuntimeException, std::exception)
104 : {
105 12 : OTypeCollection aTypes(cppu::UnoType<XPropertySet>::get(),
106 24 : OResultSetBase::getTypes());
107 :
108 12 : return aTypes.getTypes();
109 : }
110 :
111 0 : Sequence< sal_Int8 > OResultSet::getImplementationId() throw (RuntimeException, std::exception)
112 : {
113 0 : return css::uno::Sequence<sal_Int8>();
114 : }
115 :
116 : // com::sun::star::uno::XInterface
117 1024 : Any OResultSet::queryInterface( const Type & rType ) throw (RuntimeException, std::exception)
118 : {
119 1024 : Any aIface = OResultSetBase::queryInterface( rType );
120 1024 : if (!aIface.hasValue())
121 832 : aIface = ::cppu::queryInterface(
122 : rType,
123 416 : static_cast< XPropertySet * >( this ));
124 :
125 1024 : return aIface;
126 : }
127 :
128 2000 : void OResultSet::acquire() throw ()
129 : {
130 2000 : OResultSetBase::acquire();
131 2000 : }
132 :
133 1946 : void OResultSet::release() throw ()
134 : {
135 1946 : OResultSetBase::release();
136 1946 : }
137 :
138 :
139 : // OResultSetBase
140 54 : void OResultSet::disposing()
141 : {
142 54 : OPropertySetHelper::disposing();
143 :
144 54 : MutexGuard aGuard(m_aMutex);
145 :
146 : // free the columns
147 54 : m_pColumns->disposing();
148 :
149 : // close the pending result set
150 54 : Reference< XCloseable > (m_xDelegatorResultSet, UNO_QUERY)->close();
151 :
152 54 : m_xDelegatorResultSet = NULL;
153 54 : m_xDelegatorRow = NULL;
154 54 : m_xDelegatorRowUpdate = NULL;
155 :
156 54 : m_aStatement.clear();
157 54 : }
158 :
159 : // XCloseable
160 0 : void OResultSet::close(void) throw( SQLException, RuntimeException, std::exception )
161 : {
162 : {
163 0 : MutexGuard aGuard( m_aMutex );
164 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
165 : }
166 0 : dispose();
167 0 : }
168 :
169 : // XServiceInfo
170 0 : OUString OResultSet::getImplementationName( ) throw(RuntimeException, std::exception)
171 : {
172 0 : return OUString("com.sun.star.sdb.OResultSet");
173 : }
174 :
175 0 : sal_Bool OResultSet::supportsService( const OUString& _rServiceName ) throw (RuntimeException, std::exception)
176 : {
177 0 : return cppu::supportsService(this, _rServiceName);
178 : }
179 :
180 0 : Sequence< OUString > OResultSet::getSupportedServiceNames( ) throw (RuntimeException, std::exception)
181 : {
182 0 : Sequence< OUString > aSNS( 2 );
183 0 : aSNS[0] = SERVICE_SDBC_RESULTSET;
184 0 : aSNS[1] = SERVICE_SDB_RESULTSET;
185 0 : return aSNS;
186 : }
187 :
188 : // com::sun::star::beans::XPropertySet
189 50 : Reference< XPropertySetInfo > OResultSet::getPropertySetInfo() throw (RuntimeException, std::exception)
190 : {
191 50 : return createPropertySetInfo( getInfoHelper() ) ;
192 : }
193 :
194 : // comphelper::OPropertyArrayUsageHelper
195 42 : ::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
196 : {
197 42 : BEGIN_PROPERTY_HELPER(6)
198 42 : DECL_PROP1(CURSORNAME, OUString, READONLY);
199 42 : DECL_PROP0(FETCHDIRECTION, sal_Int32);
200 42 : DECL_PROP0(FETCHSIZE, sal_Int32);
201 42 : DECL_PROP1_BOOL(ISBOOKMARKABLE, READONLY);
202 42 : DECL_PROP1(RESULTSETCONCURRENCY, sal_Int32, READONLY);
203 42 : DECL_PROP1(RESULTSETTYPE, sal_Int32, READONLY);
204 42 : END_PROPERTY_HELPER();
205 : }
206 :
207 : // cppu::OPropertySetHelper
208 162 : ::cppu::IPropertyArrayHelper& OResultSet::getInfoHelper()
209 : {
210 162 : return *getArrayHelper();
211 : }
212 :
213 0 : sal_Bool OResultSet::convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw( IllegalArgumentException )
214 : {
215 : // be lazy ...
216 0 : rConvertedValue = rValue;
217 0 : getFastPropertyValue( rOldValue, nHandle );
218 0 : return sal_True;
219 : }
220 :
221 0 : void OResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception, std::exception)
222 : {
223 : // set it for the driver result set
224 0 : Reference< XPropertySet > xSet(m_xDelegatorResultSet, UNO_QUERY);
225 0 : switch (nHandle)
226 : {
227 : case PROPERTY_ID_FETCHDIRECTION:
228 0 : xSet->setPropertyValue(PROPERTY_FETCHDIRECTION, rValue);
229 0 : break;
230 : case PROPERTY_ID_FETCHSIZE:
231 0 : xSet->setPropertyValue(PROPERTY_FETCHSIZE, rValue);
232 0 : break;
233 : default:
234 : SAL_WARN("dbaccess", "unknown Property");
235 0 : }
236 0 : }
237 :
238 52 : void OResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
239 : {
240 52 : switch (nHandle)
241 : {
242 : case PROPERTY_ID_ISBOOKMARKABLE:
243 : {
244 44 : sal_Bool bVal = m_bIsBookmarkable;
245 44 : rValue.setValue(&bVal, getBooleanCppuType());
246 44 : } break;
247 : default:
248 : {
249 : // get the property name
250 8 : OUString aPropName;
251 : sal_Int16 nAttributes;
252 8 : const_cast<OResultSet*>(this)->getInfoHelper().
253 8 : fillPropertyMembersByHandle(&aPropName, &nAttributes, nHandle);
254 : OSL_ENSURE(!aPropName.isEmpty(), "property not found?");
255 :
256 : // now read the value
257 8 : rValue = Reference< XPropertySet >(m_xDelegatorResultSet, UNO_QUERY)->getPropertyValue(aPropName);
258 : }
259 : }
260 52 : }
261 :
262 : // XWarningsSupplier
263 2 : Any OResultSet::getWarnings(void) throw( SQLException, RuntimeException, std::exception )
264 : {
265 2 : MutexGuard aGuard(m_aMutex);
266 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
267 2 : return m_aWarnings.getWarnings();
268 : }
269 :
270 0 : void OResultSet::clearWarnings(void) throw( SQLException, RuntimeException, std::exception )
271 : {
272 0 : MutexGuard aGuard(m_aMutex);
273 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
274 0 : m_aWarnings.clearWarnings();
275 0 : }
276 :
277 : // ::com::sun::star::sdbc::XResultSetMetaDataSupplier
278 98 : Reference< XResultSetMetaData > OResultSet::getMetaData(void) throw( SQLException, RuntimeException, std::exception )
279 : {
280 98 : MutexGuard aGuard(m_aMutex);
281 98 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
282 :
283 98 : return Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
284 : }
285 :
286 : // ::com::sun::star::sdbc::XColumnLocate
287 16 : sal_Int32 OResultSet::findColumn(const OUString& columnName) throw( SQLException, RuntimeException, std::exception )
288 : {
289 16 : MutexGuard aGuard(m_aMutex);
290 16 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
291 :
292 16 : return Reference< XColumnLocate >(m_xDelegatorResultSet, UNO_QUERY)->findColumn(columnName);
293 : }
294 :
295 : namespace
296 : {
297 0 : static Reference< XDatabaseMetaData > lcl_getDBMetaDataFromStatement_nothrow( const Reference< XInterface >& _rxStatement )
298 : {
299 0 : Reference< XDatabaseMetaData > xDBMetaData;
300 : try
301 : {
302 0 : Reference< XStatement > xStatement( _rxStatement, UNO_QUERY );
303 0 : Reference< XPreparedStatement > xPreparedStatement( _rxStatement, UNO_QUERY );
304 0 : Reference< XConnection > xConn;
305 0 : if ( xStatement.is() )
306 0 : xConn = xStatement->getConnection();
307 0 : else if ( xPreparedStatement.is() )
308 0 : xConn = xPreparedStatement->getConnection();
309 0 : if ( xConn.is() )
310 0 : xDBMetaData = xConn->getMetaData();
311 : }
312 0 : catch( const Exception& )
313 : {
314 : DBG_UNHANDLED_EXCEPTION();
315 : }
316 0 : return xDBMetaData;
317 : }
318 : }
319 :
320 : // ::com::sun::star::sdbcx::XColumnsSupplier
321 0 : Reference< ::com::sun::star::container::XNameAccess > OResultSet::getColumns(void) throw( RuntimeException, std::exception )
322 : {
323 0 : MutexGuard aGuard(m_aMutex);
324 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
325 :
326 : // do we have to populate the columns
327 0 : if (!m_pColumns->isInitialized())
328 : {
329 : // get the metadata
330 0 : Reference< XResultSetMetaData > xMetaData = Reference< XResultSetMetaDataSupplier >(m_xDelegatorResultSet, UNO_QUERY)->getMetaData();
331 :
332 0 : sal_Int32 nColCount = 0;
333 : // do we have columns
334 : try
335 : {
336 0 : Reference< XDatabaseMetaData > xDBMetaData( lcl_getDBMetaDataFromStatement_nothrow( getStatement() ) );
337 0 : nColCount = xMetaData->getColumnCount();
338 :
339 0 : for ( sal_Int32 i = 0; i < nColCount; ++i)
340 : {
341 : // retrieve the name of the column
342 0 : OUString sName = xMetaData->getColumnName(i + 1);
343 0 : ODataColumn* pColumn = new ODataColumn(xMetaData, m_xDelegatorRow, m_xDelegatorRowUpdate, i + 1, xDBMetaData);
344 :
345 : // don't silently assume that the name is unique - result set implementations
346 : // are allowed to return duplicate names, but we are required to have
347 : // unique column names
348 0 : if ( m_pColumns->hasByName( sName ) )
349 0 : sName = ::dbtools::createUniqueName( m_pColumns, sName );
350 :
351 0 : m_pColumns->append( sName, pColumn );
352 0 : }
353 : }
354 0 : catch ( const SQLException& )
355 : {
356 : DBG_UNHANDLED_EXCEPTION();
357 : }
358 0 : m_pColumns->setInitialized();
359 :
360 : #if OSL_DEBUG_LEVEL > 0
361 : // some sanity checks. Especially in case we auto-adjusted the column names above,
362 : // this might be reasonable
363 : try
364 : {
365 : const Reference< XNameAccess > xColNames( static_cast< XNameAccess* >( m_pColumns ), UNO_SET_THROW );
366 : const Sequence< OUString > aNames( xColNames->getElementNames() );
367 : SAL_WARN_IF( aNames.getLength() != nColCount, "dbaccess",
368 : "OResultSet::getColumns: invalid column count!" );
369 : for ( const OUString* pName = aNames.getConstArray();
370 : pName != aNames.getConstArray() + aNames.getLength();
371 : ++pName
372 : )
373 : {
374 : Reference< XPropertySet > xColProps( xColNames->getByName( *pName ), UNO_QUERY_THROW );
375 : OUString sName;
376 : OSL_VERIFY( xColProps->getPropertyValue( PROPERTY_NAME ) >>= sName );
377 : SAL_WARN_IF( sName != *pName, "dbaccess", "OResultSet::getColumns: invalid column name!" );
378 : }
379 :
380 : }
381 : catch( const Exception& )
382 : {
383 : DBG_UNHANDLED_EXCEPTION();
384 : }
385 : #endif
386 : }
387 0 : return m_pColumns;
388 : }
389 :
390 : // ::com::sun::star::sdbc::XRow
391 5904 : sal_Bool OResultSet::wasNull(void) throw( SQLException, RuntimeException, std::exception )
392 : {
393 5904 : MutexGuard aGuard(m_aMutex);
394 5904 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
395 :
396 5904 : return m_xDelegatorRow->wasNull();
397 : }
398 :
399 5744 : OUString OResultSet::getString(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
400 : {
401 5744 : MutexGuard aGuard(m_aMutex);
402 5744 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
403 :
404 5744 : return m_xDelegatorRow->getString(columnIndex);
405 : }
406 :
407 56 : sal_Bool OResultSet::getBoolean(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
408 : {
409 56 : MutexGuard aGuard(m_aMutex);
410 56 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
411 :
412 56 : return m_xDelegatorRow->getBoolean(columnIndex);
413 : }
414 :
415 0 : sal_Int8 OResultSet::getByte(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
416 : {
417 0 : MutexGuard aGuard(m_aMutex);
418 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
419 :
420 0 : return m_xDelegatorRow->getByte(columnIndex);
421 : }
422 :
423 2 : sal_Int16 OResultSet::getShort(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
424 : {
425 2 : MutexGuard aGuard(m_aMutex);
426 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
427 :
428 2 : return m_xDelegatorRow->getShort(columnIndex);
429 : }
430 :
431 10 : sal_Int32 OResultSet::getInt(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
432 : {
433 10 : MutexGuard aGuard(m_aMutex);
434 10 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
435 :
436 10 : return m_xDelegatorRow->getInt(columnIndex);
437 : }
438 :
439 2 : sal_Int64 OResultSet::getLong(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
440 : {
441 2 : MutexGuard aGuard(m_aMutex);
442 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
443 :
444 2 : return m_xDelegatorRow->getLong(columnIndex);
445 : }
446 :
447 0 : float OResultSet::getFloat(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
448 : {
449 0 : MutexGuard aGuard(m_aMutex);
450 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
451 :
452 0 : return m_xDelegatorRow->getFloat(columnIndex);
453 : }
454 :
455 0 : double OResultSet::getDouble(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
456 : {
457 0 : MutexGuard aGuard(m_aMutex);
458 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
459 :
460 0 : return m_xDelegatorRow->getDouble(columnIndex);
461 : }
462 :
463 0 : Sequence< sal_Int8 > OResultSet::getBytes(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
464 : {
465 0 : MutexGuard aGuard(m_aMutex);
466 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
467 :
468 0 : return m_xDelegatorRow->getBytes(columnIndex);
469 : }
470 :
471 112 : ::com::sun::star::util::Date OResultSet::getDate(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
472 : {
473 112 : MutexGuard aGuard(m_aMutex);
474 112 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
475 :
476 112 : return m_xDelegatorRow->getDate(columnIndex);
477 : }
478 :
479 0 : ::com::sun::star::util::Time OResultSet::getTime(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
480 : {
481 0 : MutexGuard aGuard(m_aMutex);
482 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
483 :
484 0 : return m_xDelegatorRow->getTime(columnIndex);
485 : }
486 :
487 0 : ::com::sun::star::util::DateTime OResultSet::getTimestamp(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
488 : {
489 0 : MutexGuard aGuard(m_aMutex);
490 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
491 :
492 0 : return m_xDelegatorRow->getTimestamp(columnIndex);
493 : }
494 :
495 0 : Reference< ::com::sun::star::io::XInputStream > OResultSet::getBinaryStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
496 : {
497 0 : MutexGuard aGuard(m_aMutex);
498 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
499 :
500 0 : return m_xDelegatorRow->getBinaryStream(columnIndex);
501 : }
502 :
503 0 : Reference< ::com::sun::star::io::XInputStream > OResultSet::getCharacterStream(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
504 : {
505 0 : MutexGuard aGuard(m_aMutex);
506 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
507 :
508 0 : return m_xDelegatorRow->getCharacterStream(columnIndex);
509 : }
510 :
511 0 : Any OResultSet::getObject(sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess > & typeMap) throw( SQLException, RuntimeException, std::exception )
512 : {
513 0 : MutexGuard aGuard(m_aMutex);
514 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
515 :
516 0 : return m_xDelegatorRow->getObject(columnIndex, typeMap);
517 : }
518 :
519 0 : Reference< XRef > OResultSet::getRef(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
520 : {
521 0 : MutexGuard aGuard(m_aMutex);
522 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
523 :
524 0 : return m_xDelegatorRow->getRef(columnIndex);
525 : }
526 :
527 0 : Reference< XBlob > OResultSet::getBlob(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
528 : {
529 0 : MutexGuard aGuard(m_aMutex);
530 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
531 :
532 0 : return m_xDelegatorRow->getBlob(columnIndex);
533 : }
534 :
535 0 : Reference< XClob > OResultSet::getClob(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
536 : {
537 0 : MutexGuard aGuard(m_aMutex);
538 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
539 :
540 0 : return m_xDelegatorRow->getClob(columnIndex);
541 : }
542 :
543 0 : Reference< XArray > OResultSet::getArray(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
544 : {
545 0 : MutexGuard aGuard(m_aMutex);
546 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
547 :
548 0 : return m_xDelegatorRow->getArray(columnIndex);
549 : }
550 :
551 : // ::com::sun::star::sdbc::XRowUpdate
552 0 : void OResultSet::updateNull(sal_Int32 columnIndex) throw( SQLException, RuntimeException, std::exception )
553 : {
554 0 : MutexGuard aGuard(m_aMutex);
555 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
556 :
557 0 : checkReadOnly();
558 :
559 0 : m_xDelegatorRowUpdate->updateNull(columnIndex);
560 0 : }
561 :
562 0 : void OResultSet::updateBoolean(sal_Int32 columnIndex, sal_Bool x) throw( SQLException, RuntimeException, std::exception )
563 : {
564 0 : MutexGuard aGuard(m_aMutex);
565 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
566 :
567 0 : checkReadOnly();
568 :
569 0 : m_xDelegatorRowUpdate->updateBoolean(columnIndex, x);
570 0 : }
571 :
572 0 : void OResultSet::updateByte(sal_Int32 columnIndex, sal_Int8 x) throw( SQLException, RuntimeException, std::exception )
573 : {
574 0 : MutexGuard aGuard(m_aMutex);
575 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
576 :
577 0 : checkReadOnly();
578 :
579 0 : m_xDelegatorRowUpdate->updateByte(columnIndex, x);
580 0 : }
581 :
582 0 : void OResultSet::updateShort(sal_Int32 columnIndex, sal_Int16 x) throw( SQLException, RuntimeException, std::exception )
583 : {
584 0 : MutexGuard aGuard(m_aMutex);
585 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
586 :
587 0 : checkReadOnly();
588 :
589 0 : m_xDelegatorRowUpdate->updateShort(columnIndex, x);
590 0 : }
591 :
592 0 : void OResultSet::updateInt(sal_Int32 columnIndex, sal_Int32 x) throw( SQLException, RuntimeException, std::exception )
593 : {
594 0 : MutexGuard aGuard(m_aMutex);
595 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
596 :
597 0 : checkReadOnly();
598 :
599 0 : m_xDelegatorRowUpdate->updateInt(columnIndex, x);
600 0 : }
601 :
602 0 : void OResultSet::updateLong(sal_Int32 columnIndex, sal_Int64 x) throw( SQLException, RuntimeException, std::exception )
603 : {
604 0 : MutexGuard aGuard(m_aMutex);
605 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
606 :
607 0 : checkReadOnly();
608 :
609 0 : m_xDelegatorRowUpdate->updateLong(columnIndex, x);
610 0 : }
611 :
612 0 : void OResultSet::updateFloat(sal_Int32 columnIndex, float x) throw( SQLException, RuntimeException, std::exception )
613 : {
614 0 : MutexGuard aGuard(m_aMutex);
615 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
616 :
617 0 : checkReadOnly();
618 :
619 0 : m_xDelegatorRowUpdate->updateFloat(columnIndex, x);
620 0 : }
621 :
622 0 : void OResultSet::updateDouble(sal_Int32 columnIndex, double x) throw( SQLException, RuntimeException, std::exception )
623 : {
624 0 : MutexGuard aGuard(m_aMutex);
625 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
626 :
627 0 : checkReadOnly();
628 :
629 0 : m_xDelegatorRowUpdate->updateDouble(columnIndex, x);
630 0 : }
631 :
632 10 : void OResultSet::updateString(sal_Int32 columnIndex, const OUString& x) throw( SQLException, RuntimeException, std::exception )
633 : {
634 10 : MutexGuard aGuard(m_aMutex);
635 10 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
636 :
637 10 : checkReadOnly();
638 :
639 10 : m_xDelegatorRowUpdate->updateString(columnIndex, x);
640 10 : }
641 :
642 0 : void OResultSet::updateBytes(sal_Int32 columnIndex, const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException, std::exception )
643 : {
644 0 : MutexGuard aGuard(m_aMutex);
645 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
646 :
647 0 : checkReadOnly();
648 :
649 0 : m_xDelegatorRowUpdate->updateBytes(columnIndex, x);
650 0 : }
651 :
652 0 : void OResultSet::updateDate(sal_Int32 columnIndex, const ::com::sun::star::util::Date& x) throw( SQLException, RuntimeException, std::exception )
653 : {
654 0 : MutexGuard aGuard(m_aMutex);
655 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
656 :
657 0 : checkReadOnly();
658 :
659 0 : m_xDelegatorRowUpdate->updateDate(columnIndex, x);
660 0 : }
661 :
662 0 : void OResultSet::updateTime(sal_Int32 columnIndex, const ::com::sun::star::util::Time& x) throw( SQLException, RuntimeException, std::exception )
663 : {
664 0 : MutexGuard aGuard(m_aMutex);
665 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
666 :
667 0 : checkReadOnly();
668 :
669 0 : m_xDelegatorRowUpdate->updateTime(columnIndex, x);
670 0 : }
671 :
672 0 : void OResultSet::updateTimestamp(sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException, std::exception )
673 : {
674 0 : MutexGuard aGuard(m_aMutex);
675 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
676 :
677 0 : checkReadOnly();
678 :
679 0 : m_xDelegatorRowUpdate->updateTimestamp(columnIndex, x);
680 0 : }
681 :
682 0 : void OResultSet::updateBinaryStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException, std::exception )
683 : {
684 0 : MutexGuard aGuard(m_aMutex);
685 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
686 :
687 0 : checkReadOnly();
688 :
689 0 : m_xDelegatorRowUpdate->updateBinaryStream(columnIndex, x, length);
690 0 : }
691 :
692 0 : void OResultSet::updateCharacterStream(sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream > & x, sal_Int32 length) throw( SQLException, RuntimeException, std::exception )
693 : {
694 0 : MutexGuard aGuard(m_aMutex);
695 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
696 :
697 0 : checkReadOnly();
698 :
699 0 : m_xDelegatorRowUpdate->updateCharacterStream(columnIndex, x, length);
700 0 : }
701 :
702 0 : void OResultSet::updateNumericObject(sal_Int32 columnIndex, const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException, std::exception )
703 : {
704 0 : MutexGuard aGuard(m_aMutex);
705 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
706 :
707 0 : checkReadOnly();
708 :
709 0 : m_xDelegatorRowUpdate->updateNumericObject(columnIndex, x, scale);
710 0 : }
711 :
712 0 : void OResultSet::updateObject(sal_Int32 columnIndex, const Any& x) throw( SQLException, RuntimeException, std::exception )
713 : {
714 0 : MutexGuard aGuard(m_aMutex);
715 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
716 :
717 0 : checkReadOnly();
718 :
719 0 : m_xDelegatorRowUpdate->updateObject(columnIndex, x);
720 0 : }
721 :
722 : // ::com::sun::star::sdbc::XResultSet
723 368 : sal_Bool OResultSet::next(void) throw( SQLException, RuntimeException, std::exception )
724 : {
725 368 : MutexGuard aGuard(m_aMutex);
726 368 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
727 :
728 368 : return m_xDelegatorResultSet->next();
729 : }
730 :
731 0 : sal_Bool OResultSet::isBeforeFirst(void) throw( SQLException, RuntimeException, std::exception )
732 : {
733 0 : MutexGuard aGuard(m_aMutex);
734 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
735 :
736 0 : return m_xDelegatorResultSet->isBeforeFirst();
737 : }
738 :
739 0 : sal_Bool OResultSet::isAfterLast(void) throw( SQLException, RuntimeException, std::exception )
740 : {
741 0 : MutexGuard aGuard(m_aMutex);
742 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
743 :
744 0 : return m_xDelegatorResultSet->isAfterLast();
745 : }
746 :
747 0 : sal_Bool OResultSet::isFirst(void) throw( SQLException, RuntimeException, std::exception )
748 : {
749 0 : MutexGuard aGuard(m_aMutex);
750 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
751 :
752 0 : return m_xDelegatorResultSet->isFirst();
753 : }
754 :
755 0 : sal_Bool OResultSet::isLast(void) throw( SQLException, RuntimeException, std::exception )
756 : {
757 0 : MutexGuard aGuard(m_aMutex);
758 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
759 :
760 0 : return m_xDelegatorResultSet->isLast();
761 : }
762 :
763 60 : void OResultSet::beforeFirst(void) throw( SQLException, RuntimeException, std::exception )
764 : {
765 60 : MutexGuard aGuard(m_aMutex);
766 60 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
767 :
768 60 : m_xDelegatorResultSet->beforeFirst();
769 60 : }
770 :
771 10 : void OResultSet::afterLast(void) throw( SQLException, RuntimeException, std::exception )
772 : {
773 10 : MutexGuard aGuard(m_aMutex);
774 10 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
775 :
776 10 : m_xDelegatorResultSet->afterLast();
777 10 : }
778 :
779 58 : sal_Bool OResultSet::first(void) throw( SQLException, RuntimeException, std::exception )
780 : {
781 58 : MutexGuard aGuard(m_aMutex);
782 58 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
783 :
784 58 : return m_xDelegatorResultSet->first();
785 : }
786 :
787 8 : sal_Bool OResultSet::last(void) throw( SQLException, RuntimeException, std::exception )
788 : {
789 8 : MutexGuard aGuard(m_aMutex);
790 8 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
791 :
792 8 : return m_xDelegatorResultSet->last();
793 : }
794 :
795 76 : sal_Int32 OResultSet::getRow(void) throw( SQLException, RuntimeException, std::exception )
796 : {
797 76 : MutexGuard aGuard(m_aMutex);
798 76 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
799 :
800 76 : return m_xDelegatorResultSet->getRow();
801 : }
802 :
803 140 : sal_Bool OResultSet::absolute(sal_Int32 row) throw( SQLException, RuntimeException, std::exception )
804 : {
805 140 : MutexGuard aGuard(m_aMutex);
806 140 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
807 :
808 140 : return m_xDelegatorResultSet->absolute(row);
809 : }
810 :
811 0 : sal_Bool OResultSet::relative(sal_Int32 rows) throw( SQLException, RuntimeException, std::exception )
812 : {
813 0 : MutexGuard aGuard(m_aMutex);
814 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
815 :
816 0 : return m_xDelegatorResultSet->relative(rows);
817 : }
818 :
819 46 : sal_Bool OResultSet::previous(void) throw( SQLException, RuntimeException, std::exception )
820 : {
821 46 : MutexGuard aGuard(m_aMutex);
822 46 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
823 :
824 46 : return m_xDelegatorResultSet->previous();
825 : }
826 :
827 2 : void OResultSet::refreshRow(void) throw( SQLException, RuntimeException, std::exception )
828 : {
829 2 : MutexGuard aGuard(m_aMutex);
830 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
831 :
832 2 : m_xDelegatorResultSet->refreshRow();
833 2 : }
834 :
835 2 : sal_Bool OResultSet::rowUpdated(void) throw( SQLException, RuntimeException, std::exception )
836 : {
837 2 : MutexGuard aGuard(m_aMutex);
838 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
839 :
840 2 : return m_xDelegatorResultSet->rowUpdated();
841 : }
842 :
843 4 : sal_Bool OResultSet::rowInserted(void) throw( SQLException, RuntimeException, std::exception )
844 : {
845 4 : MutexGuard aGuard(m_aMutex);
846 4 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
847 :
848 4 : return m_xDelegatorResultSet->rowInserted();
849 : }
850 :
851 2 : sal_Bool OResultSet::rowDeleted(void) throw( SQLException, RuntimeException, std::exception )
852 : {
853 2 : MutexGuard aGuard(m_aMutex);
854 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
855 :
856 2 : return m_xDelegatorResultSet->rowDeleted();
857 : }
858 :
859 100 : Reference< XInterface > OResultSet::getStatement(void) throw( SQLException, RuntimeException, std::exception )
860 : {
861 100 : MutexGuard aGuard(m_aMutex);
862 100 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
863 :
864 100 : return m_aStatement;
865 : }
866 :
867 : // ::com::sun::star::sdbcx::XRowLocate
868 358 : Any OResultSet::getBookmark(void) throw( SQLException, RuntimeException, std::exception )
869 : {
870 358 : MutexGuard aGuard(m_aMutex);
871 358 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
872 :
873 358 : checkBookmarkable();
874 :
875 358 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->getBookmark();
876 : }
877 :
878 32 : sal_Bool OResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException, std::exception )
879 : {
880 32 : MutexGuard aGuard(m_aMutex);
881 32 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
882 :
883 32 : checkBookmarkable();
884 :
885 32 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveToBookmark(bookmark);
886 : }
887 :
888 0 : sal_Bool OResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException, std::exception )
889 : {
890 0 : MutexGuard aGuard(m_aMutex);
891 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
892 :
893 0 : checkBookmarkable();
894 :
895 0 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->moveRelativeToBookmark(bookmark, rows);
896 : }
897 :
898 286 : sal_Int32 OResultSet::compareBookmarks(const Any& _first, const Any& _second) throw( SQLException, RuntimeException, std::exception )
899 : {
900 286 : MutexGuard aGuard(m_aMutex);
901 286 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
902 :
903 286 : checkBookmarkable();
904 :
905 286 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->compareBookmarks(_first, _second);
906 : }
907 :
908 2 : sal_Bool OResultSet::hasOrderedBookmarks(void) throw( SQLException, RuntimeException, std::exception )
909 : {
910 2 : MutexGuard aGuard(m_aMutex);
911 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
912 :
913 2 : checkBookmarkable();
914 :
915 2 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hasOrderedBookmarks();
916 : }
917 :
918 4 : sal_Int32 OResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException, std::exception )
919 : {
920 4 : MutexGuard aGuard(m_aMutex);
921 4 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
922 :
923 4 : checkBookmarkable();
924 :
925 4 : return Reference< XRowLocate >(m_xDelegatorResultSet, UNO_QUERY)->hashBookmark(bookmark);
926 : }
927 :
928 : // ::com::sun::star::sdbc::XResultSetUpdate
929 2 : void OResultSet::insertRow(void) throw( SQLException, RuntimeException, std::exception )
930 : {
931 2 : MutexGuard aGuard(m_aMutex);
932 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
933 :
934 2 : checkReadOnly();
935 :
936 2 : m_xDelegatorResultSetUpdate->insertRow();
937 2 : }
938 :
939 8 : void OResultSet::updateRow(void) throw( SQLException, RuntimeException, std::exception )
940 : {
941 8 : MutexGuard aGuard(m_aMutex);
942 8 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
943 :
944 8 : checkReadOnly();
945 :
946 8 : m_xDelegatorResultSetUpdate->updateRow();
947 8 : }
948 :
949 2 : void OResultSet::deleteRow(void) throw( SQLException, RuntimeException, std::exception )
950 : {
951 2 : MutexGuard aGuard(m_aMutex);
952 2 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
953 :
954 2 : checkReadOnly();
955 :
956 2 : m_xDelegatorResultSetUpdate->deleteRow();
957 2 : }
958 :
959 40 : void OResultSet::cancelRowUpdates(void) throw( SQLException, RuntimeException, std::exception )
960 : {
961 40 : MutexGuard aGuard(m_aMutex);
962 40 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
963 :
964 40 : checkReadOnly();
965 :
966 40 : m_xDelegatorResultSetUpdate->cancelRowUpdates();
967 40 : }
968 :
969 46 : void OResultSet::moveToInsertRow(void) throw( SQLException, RuntimeException, std::exception )
970 : {
971 46 : MutexGuard aGuard(m_aMutex);
972 46 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
973 :
974 46 : checkReadOnly();
975 :
976 46 : m_xDelegatorResultSetUpdate->moveToInsertRow();
977 42 : }
978 :
979 0 : void OResultSet::moveToCurrentRow(void) throw( SQLException, RuntimeException, std::exception )
980 : {
981 0 : MutexGuard aGuard(m_aMutex);
982 0 : ::connectivity::checkDisposed(OResultSetBase::rBHelper.bDisposed);
983 :
984 0 : checkReadOnly();
985 :
986 0 : m_xDelegatorResultSetUpdate->moveToCurrentRow();
987 0 : }
988 :
989 108 : void OResultSet::checkReadOnly() const
990 : {
991 216 : if ( ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
992 108 : || !m_xDelegatorResultSetUpdate.is()
993 : )
994 8 : throwSQLException( "The result set is read-only.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
995 104 : }
996 :
997 682 : void OResultSet::checkBookmarkable() const
998 : {
999 682 : if ( !m_bIsBookmarkable )
1000 0 : throwSQLException( "The result set does not have bookmark support.", SQL_GENERAL_ERROR, *const_cast< OResultSet* >( this ) );
1001 682 : }
1002 :
1003 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|