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 "mysqlc_propertyids.hxx"
21 #include "mysqlc_general.hxx"
22 #include "mysqlc_resultset.hxx"
23 #include "mysqlc_resultsetmetadata.hxx"
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <com/sun/star/lang/DisposedException.hpp>
27 #include <com/sun/star/sdbc/DataType.hpp>
28 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
29 #include <com/sun/star/sdbc/ResultSetType.hpp>
30 #include <com/sun/star/sdbc/FetchDirection.hpp>
31 #include <com/sun/star/sdbcx/CompareBookmark.hpp>
32 #include <cppuhelper/supportsservice.hxx>
33 #include <cppuhelper/typeprovider.hxx>
35 using namespace connectivity::mysqlc
;
37 using namespace com::sun::star::uno
;
38 using namespace com::sun::star::lang
;
39 using namespace com::sun::star::beans
;
40 using namespace com::sun::star::sdbc
;
41 using namespace com::sun::star::sdbcx
;
42 using namespace com::sun::star::container
;
43 using namespace com::sun::star::io
;
44 using namespace com::sun::star::util
;
45 using ::osl::MutexGuard
;
47 #include <cppconn/resultset.h>
48 #include <cppconn/resultset_metadata.h>
52 rtl::OUString SAL_CALL
OResultSet::getImplementationName()
53 throw (RuntimeException
, std::exception
)
55 OSL_TRACE("OResultSet::getImplementationName");
56 return rtl::OUString( "com.sun.star.sdbcx.mysqlc.ResultSet" );
59 Sequence
< rtl::OUString
> SAL_CALL
OResultSet::getSupportedServiceNames()
60 throw(RuntimeException
, std::exception
)
62 OSL_TRACE("OResultSet::getSupportedServiceNames");
63 Sequence
< rtl::OUString
> aSupported(2);
64 aSupported
[0] = "com.sun.star.sdbc.ResultSet";
65 aSupported
[1] = "com.sun.star.sdbcx.ResultSet";
69 sal_Bool SAL_CALL
OResultSet::supportsService(const rtl::OUString
& _rServiceName
)
70 throw(RuntimeException
, std::exception
)
72 return cppu::supportsService(this, _rServiceName
);
75 OResultSet::OResultSet(OCommonStatement
* pStmt
, sql::ResultSet
* result
, rtl_TextEncoding _encoding
)
76 : OResultSet_BASE(m_aMutex
)
77 ,OPropertySetHelper(OResultSet_BASE::rBHelper
)
78 ,m_aStatement((OWeakObject
*)pStmt
)
82 ,m_encoding( _encoding
)
84 OSL_TRACE("OResultSet::OResultSet");
86 sql::ResultSetMetaData
* rs_meta
= m_result
->getMetaData();
87 fieldCount
= rs_meta
->getColumnCount();
88 } catch (const sql::SQLException
&e
) {
89 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
93 OResultSet::~OResultSet()
95 OSL_TRACE("OResultSet::~OResultSet");
98 void OResultSet::disposing()
100 OSL_TRACE("OResultSet::disposing");
101 OPropertySetHelper::disposing();
103 MutexGuard
aGuard(m_aMutex
);
109 Any SAL_CALL
OResultSet::queryInterface(const Type
& rType
)
110 throw(RuntimeException
, std::exception
)
112 OSL_TRACE("OResultSet::queryInterface");
113 Any aRet
= OPropertySetHelper::queryInterface(rType
);
114 if (!aRet
.hasValue()) {
115 aRet
= OResultSet_BASE::queryInterface(rType
);
120 Sequence
< Type
> SAL_CALL
OResultSet::getTypes()
121 throw(RuntimeException
, std::exception
)
123 OSL_TRACE("OResultSet::getTypes");
124 OTypeCollection
aTypes( cppu::UnoType
<XMultiPropertySet
>::get(),
125 cppu::UnoType
<XFastPropertySet
>::get(),
126 cppu::UnoType
<XPropertySet
>::get());
128 return concatSequences(aTypes
.getTypes(), OResultSet_BASE::getTypes());
131 sal_Int32 SAL_CALL
OResultSet::findColumn(const rtl::OUString
& columnName
)
132 throw(SQLException
, RuntimeException
, std::exception
)
134 OSL_TRACE("OResultSet::findColumn");
135 MutexGuard
aGuard(m_aMutex
);
136 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
139 // find the first column with the name columnName
140 sql::ResultSetMetaData
* meta
= m_result
->getMetaData();
141 for (sal_uInt32 i
= 1; i
<= fieldCount
; i
++) {
142 if (columnName
.equalsIgnoreAsciiCaseAscii(meta
->getColumnName(i
).c_str())) {
143 /* SDBC knows them indexed from 1 */
147 } catch (const sql::SQLException
&e
) {
148 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
151 "The column name '" + columnName
+ "' is not valid.",
153 rtl::OUString("42S22"),
159 Reference
< XInputStream
> SAL_CALL
OResultSet::getBinaryStream(sal_Int32 column
)
160 throw(SQLException
, RuntimeException
, std::exception
)
162 OSL_TRACE("OResultSet::getBinaryStream");
163 MutexGuard
aGuard(m_aMutex
);
164 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
165 checkColumnIndex(column
);
167 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getBinaryStream", *this);
171 Reference
< XInputStream
> SAL_CALL
OResultSet::getCharacterStream(sal_Int32 column
)
172 throw(SQLException
, RuntimeException
, std::exception
)
174 OSL_TRACE("OResultSet::getCharacterStream");
175 MutexGuard
aGuard(m_aMutex
);
176 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
177 checkColumnIndex(column
);
179 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getCharacterStream", *this);
183 sal_Bool SAL_CALL
OResultSet::getBoolean(sal_Int32 column
)
184 throw(SQLException
, RuntimeException
, std::exception
)
186 OSL_TRACE("OResultSet::getBoolean");
187 MutexGuard
aGuard(m_aMutex
);
188 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
190 checkColumnIndex(column
);
192 return m_result
->getBoolean(column
)? sal_True
:sal_False
;
193 } catch (const sql::SQLException
&e
) {
194 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
199 sal_Int8 SAL_CALL
OResultSet::getByte(sal_Int32 column
)
200 throw(SQLException
, RuntimeException
, std::exception
)
202 OSL_TRACE("OResultSet::getByte");
203 MutexGuard
aGuard(m_aMutex
);
204 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
206 checkColumnIndex(column
);
208 return m_result
->getInt(column
);
209 } catch (const sql::SQLException
&e
) {
210 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
212 return 0; // fool compiler
215 Sequence
< sal_Int8
> SAL_CALL
OResultSet::getBytes(sal_Int32 column
)
216 throw(SQLException
, RuntimeException
, std::exception
)
218 OSL_TRACE("OResultSet::getBytes");
220 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
221 MutexGuard
aGuard(m_aMutex
);
223 sql::SQLString val
= m_result
->getString(column
);
225 return Sequence
< sal_Int8
>();
227 return Sequence
< sal_Int8
> (reinterpret_cast<sal_Int8
const *>(val
.c_str()), val
.length());
231 Date SAL_CALL
OResultSet::getDate(sal_Int32 column
)
232 throw(SQLException
, RuntimeException
, std::exception
)
234 OSL_TRACE("OResultSet::getDate");
235 MutexGuard
aGuard(m_aMutex
);
236 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
237 checkColumnIndex(column
);
241 rtl::OUString dateString
= getString(column
);
243 sal_Int32 nIndex
= 0, i
=0;
246 token
= dateString
.getToken (0, '-', nIndex
);
249 d
.Year
= static_cast<sal_uInt16
>(token
.toUInt32());
252 d
.Month
= static_cast<sal_uInt16
>(token
.toUInt32());
255 d
.Day
= static_cast<sal_uInt16
>(token
.toUInt32());
260 } while (nIndex
>= 0);
261 } catch (const sql::SQLException
&e
) {
262 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
267 double SAL_CALL
OResultSet::getDouble(sal_Int32 column
)
268 throw(SQLException
, RuntimeException
, std::exception
)
270 OSL_TRACE("OResultSet::getDouble");
271 MutexGuard
aGuard(m_aMutex
);
272 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
274 checkColumnIndex(column
);
276 return m_result
->getDouble(column
);
277 } catch (const sql::SQLException
&e
) {
278 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
280 return 0.0; // fool compiler
283 float SAL_CALL
OResultSet::getFloat(sal_Int32 column
)
284 throw(SQLException
, RuntimeException
, std::exception
)
286 OSL_TRACE("OResultSet::getFloat");
287 MutexGuard
aGuard(m_aMutex
);
288 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
290 checkColumnIndex(column
);
292 return m_result
->getDouble(column
);
293 } catch (const sql::SQLException
&e
) {
294 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
296 return 0.0; // fool compiler
299 sal_Int32 SAL_CALL
OResultSet::getInt(sal_Int32 column
)
300 throw(SQLException
, RuntimeException
, std::exception
)
302 OSL_TRACE("OResultSet::getInt");
303 MutexGuard
aGuard(m_aMutex
);
304 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
306 checkColumnIndex(column
);
308 return m_result
->getInt(column
);
309 } catch (const sql::SQLException
&e
) {
310 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
312 return 0; // fool compiler
315 sal_Int32 SAL_CALL
OResultSet::getRow()
316 throw(SQLException
, RuntimeException
, std::exception
)
318 OSL_TRACE("OResultSet::getRow");
319 MutexGuard
aGuard(m_aMutex
);
320 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
323 return m_result
->getRow();
324 } catch (const sql::SQLException
&e
) {
325 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
327 return 0; // fool compiler
330 sal_Int64 SAL_CALL
OResultSet::getLong(sal_Int32 column
)
331 throw(SQLException
, RuntimeException
, std::exception
)
333 OSL_TRACE("OResultSet::getLong");
334 MutexGuard
aGuard(m_aMutex
);
335 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
337 checkColumnIndex(column
);
339 return m_result
->getInt64(column
);
340 } catch (const sql::SQLException
&e
) {
341 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
343 return 0; // fool compiler
346 Reference
< XResultSetMetaData
> SAL_CALL
OResultSet::getMetaData()
347 throw(SQLException
, RuntimeException
, std::exception
)
349 OSL_TRACE("OResultSet::getMetaData");
350 MutexGuard
aGuard(m_aMutex
);
351 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
353 if (!m_xMetaData
.is()) {
354 m_xMetaData
= new OResultSetMetaData(m_result
->getMetaData(), m_encoding
);
356 } catch (const sql::MethodNotImplementedException
&) {
357 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getMetaData", *this);
358 } catch (const sql::SQLException
&e
) {
359 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
364 Reference
< XArray
> SAL_CALL
OResultSet::getArray(sal_Int32 column
)
365 throw(SQLException
, RuntimeException
, std::exception
)
367 OSL_TRACE("OResultSet::getArray");
368 MutexGuard
aGuard(m_aMutex
);
369 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
370 checkColumnIndex(column
);
372 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getArray", *this);
376 Reference
< XClob
> SAL_CALL
OResultSet::getClob(sal_Int32 column
)
377 throw(SQLException
, RuntimeException
, std::exception
)
379 OSL_TRACE("OResultSet::getClob");
380 MutexGuard
aGuard(m_aMutex
);
381 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
382 checkColumnIndex(column
);
384 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getClob", *this);
388 Reference
< XBlob
> SAL_CALL
OResultSet::getBlob(sal_Int32 column
)
389 throw(SQLException
, RuntimeException
, std::exception
)
391 OSL_TRACE("OResultSet::getBlob");
392 MutexGuard
aGuard(m_aMutex
);
393 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
394 checkColumnIndex(column
);
396 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getBlob", *this);
400 Reference
< XRef
> SAL_CALL
OResultSet::getRef(sal_Int32 column
)
401 throw(SQLException
, RuntimeException
, std::exception
)
403 OSL_TRACE("OResultSet::getRef");
404 MutexGuard
aGuard(m_aMutex
);
405 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
406 checkColumnIndex(column
);
408 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getRef", *this);
412 Any SAL_CALL
OResultSet::getObject(sal_Int32 column
, const Reference
< XNameAccess
>& /* typeMap */)
413 throw(SQLException
, RuntimeException
, std::exception
)
415 OSL_TRACE("OResultSet::getObject");
416 MutexGuard
aGuard(m_aMutex
);
417 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
418 checkColumnIndex(column
);
422 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getObject", *this);
426 sal_Int16 SAL_CALL
OResultSet::getShort(sal_Int32 column
)
427 throw(SQLException
, RuntimeException
, std::exception
)
429 OSL_TRACE("OResultSet::getShort");
430 MutexGuard
aGuard(m_aMutex
);
431 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
434 return (sal_Int16
) m_result
->getInt(column
);
435 } catch (const sql::SQLException
&e
) {
436 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
438 return 0; // fool compiler
441 rtl::OUString SAL_CALL
OResultSet::getString(sal_Int32 column
)
442 throw(SQLException
, RuntimeException
, std::exception
)
444 OSL_TRACE("OResultSet::getString");
445 MutexGuard
aGuard(m_aMutex
);
446 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
448 checkColumnIndex(column
);
451 sql::SQLString val
= m_result
->getString(column
);
452 if (!m_result
->wasNull()) {
453 return rtl::OUString( val
.c_str(), val
.length(), m_encoding
);
455 return rtl::OUString();
457 } catch (const sql::SQLException
&e
) {
458 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
460 return rtl::OUString(); // fool compiler
463 Time SAL_CALL
OResultSet::getTime(sal_Int32 column
)
464 throw(SQLException
, RuntimeException
, std::exception
)
466 OSL_TRACE("OResultSet::getTime");
467 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
468 MutexGuard
aGuard(m_aMutex
);
470 checkColumnIndex(column
);
472 rtl::OUString timeString
= getString(column
);
474 sal_Int32 nIndex
, i
=0;
476 nIndex
= timeString
.indexOf(' ') + 1;
479 token
= timeString
.getToken (0, ':', nIndex
);
482 t
.Hours
= static_cast<sal_uInt16
>(token
.toUInt32());
485 t
.Minutes
= static_cast<sal_uInt16
>(token
.toUInt32());
488 t
.Seconds
= static_cast<sal_uInt16
>(token
.toUInt32());
492 } while (nIndex
>= 0);
497 DateTime SAL_CALL
OResultSet::getTimestamp(sal_Int32 column
)
498 throw(SQLException
, RuntimeException
, std::exception
)
500 OSL_TRACE("OResultSet::getTimestamp");
501 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
502 MutexGuard
aGuard(m_aMutex
);
504 checkColumnIndex(column
);
506 Date d
= getDate(column
);
507 Time t
= getTime(column
);
513 dt
.Minutes
= t
.Minutes
;
514 dt
.Seconds
= t
.Seconds
;
518 sal_Bool SAL_CALL
OResultSet::isBeforeFirst()
519 throw(SQLException
, RuntimeException
, std::exception
)
521 OSL_TRACE("OResultSet::isBeforeFirst");
522 MutexGuard
aGuard(m_aMutex
);
523 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
526 return m_result
->isBeforeFirst()? sal_True
:sal_False
;
527 } catch (const sql::SQLException
&e
) {
528 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
530 return sal_False
; //fool
533 sal_Bool SAL_CALL
OResultSet::isAfterLast()
534 throw(SQLException
, RuntimeException
, std::exception
)
536 OSL_TRACE("OResultSet::isAfterLast");
537 MutexGuard
aGuard(m_aMutex
);
538 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
541 return m_result
->isAfterLast()? sal_True
:sal_False
;
542 } catch (const sql::SQLException
&e
) {
543 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
545 return sal_False
; //fool
548 sal_Bool SAL_CALL
OResultSet::isFirst()
549 throw(SQLException
, RuntimeException
, std::exception
)
551 OSL_TRACE("OResultSet::isFirst");
552 MutexGuard
aGuard(m_aMutex
);
553 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
556 return m_result
->isFirst();
557 } catch (const sql::SQLException
&e
) {
558 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
560 return sal_False
; //fool
563 sal_Bool SAL_CALL
OResultSet::isLast()
564 throw(SQLException
, RuntimeException
, std::exception
)
566 OSL_TRACE("OResultSet::isLast");
567 MutexGuard
aGuard(m_aMutex
);
568 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
571 return m_result
->isLast()? sal_True
:sal_False
;
572 } catch (const sql::SQLException
&e
) {
573 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
575 return sal_False
; //fool
578 void SAL_CALL
OResultSet::beforeFirst()
579 throw(SQLException
, RuntimeException
, std::exception
)
581 OSL_TRACE("OResultSet::beforeFirst");
582 MutexGuard
aGuard(m_aMutex
);
583 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
586 m_result
->beforeFirst();
587 } catch (const sql::SQLException
&e
) {
588 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
592 void SAL_CALL
OResultSet::afterLast()
593 throw(SQLException
, RuntimeException
, std::exception
)
595 OSL_TRACE("OResultSet::afterLast");
596 MutexGuard
aGuard(m_aMutex
);
597 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
600 m_result
->afterLast();
601 } catch (const sql::SQLException
&e
) {
602 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
606 void SAL_CALL
OResultSet::close() throw(SQLException
, RuntimeException
, std::exception
)
608 OSL_TRACE("OResultSet::close");
609 MutexGuard
aGuard(m_aMutex
);
610 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
614 } catch (const sql::SQLException
&e
) {
615 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
621 sal_Bool SAL_CALL
OResultSet::first() throw(SQLException
, RuntimeException
, std::exception
)
623 OSL_TRACE("OResultSet::first");
624 MutexGuard
aGuard(m_aMutex
);
625 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
628 return m_result
->first()? sal_True
:sal_False
;
629 } catch (const sql::SQLException
&e
) {
630 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
632 return sal_False
; //fool
635 sal_Bool SAL_CALL
OResultSet::last()
636 throw(SQLException
, RuntimeException
, std::exception
)
638 OSL_TRACE("OResultSet::last");
639 MutexGuard
aGuard(m_aMutex
);
640 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
643 return m_result
->last()? sal_True
:sal_False
;
644 } catch (const sql::SQLException
&e
) {
645 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
647 return sal_False
; //fool
650 sal_Bool SAL_CALL
OResultSet::absolute(sal_Int32 row
)
651 throw(SQLException
, RuntimeException
, std::exception
)
653 OSL_TRACE("OResultSet::absolute");
654 MutexGuard
aGuard(m_aMutex
);
655 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
658 return m_result
->absolute(row
)? sal_True
:sal_False
;
659 } catch (const sql::SQLException
&e
) {
660 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
662 return sal_False
; //fool
665 sal_Bool SAL_CALL
OResultSet::relative(sal_Int32 row
)
666 throw(SQLException
, RuntimeException
, std::exception
)
668 OSL_TRACE("OResultSet::relative");
669 MutexGuard
aGuard(m_aMutex
);
670 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
673 return m_result
->relative(row
)? sal_True
:sal_False
;
674 } catch (const sql::SQLException
&e
) {
675 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
677 return sal_False
; //fool
680 sal_Bool SAL_CALL
OResultSet::previous()
681 throw(SQLException
, RuntimeException
, std::exception
)
683 OSL_TRACE("OResultSet::previous");
684 MutexGuard
aGuard(m_aMutex
);
685 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
688 return m_result
->previous()? sal_True
:sal_False
;
689 } catch (const sql::SQLException
&e
) {
690 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
692 return sal_False
; //fool
695 Reference
< XInterface
> SAL_CALL
OResultSet::getStatement()
696 throw(SQLException
, RuntimeException
, std::exception
)
698 OSL_TRACE("OResultSet::getStatement");
699 MutexGuard
aGuard(m_aMutex
);
700 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
702 return m_aStatement
.get();
705 sal_Bool SAL_CALL
OResultSet::rowDeleted()
706 throw(SQLException
, RuntimeException
, std::exception
)
708 OSL_TRACE("OResultSet::rowDeleted");
709 MutexGuard
aGuard(m_aMutex
);
710 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
715 sal_Bool SAL_CALL
OResultSet::rowInserted()
716 throw(SQLException
, RuntimeException
, std::exception
)
718 OSL_TRACE("OResultSet::rowInserted");
719 MutexGuard
aGuard(m_aMutex
);
720 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
725 sal_Bool SAL_CALL
OResultSet::rowUpdated()
726 throw(SQLException
, RuntimeException
, std::exception
)
728 OSL_TRACE("OResultSet::rowUpdated");
729 MutexGuard
aGuard(m_aMutex
);
730 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
735 sal_Bool SAL_CALL
OResultSet::next()
736 throw(SQLException
, RuntimeException
, std::exception
)
738 OSL_TRACE("OResultSet::next");
739 MutexGuard
aGuard(m_aMutex
);
740 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
743 return m_result
->next()? sal_True
:sal_False
;
744 } catch (const sql::SQLException
&e
) {
745 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
747 return sal_False
; //fool
750 sal_Bool SAL_CALL
OResultSet::wasNull()
751 throw(SQLException
, RuntimeException
, std::exception
)
753 OSL_TRACE("OResultSet::wasNull");
754 MutexGuard
aGuard(m_aMutex
);
755 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
758 return m_result
->wasNull()? sal_True
:sal_False
;
759 } catch (const sql::SQLException
&e
) {
760 mysqlc_sdbc_driver::translateAndThrow(e
, *this, m_encoding
);
762 return sal_False
; //fool
765 void SAL_CALL
OResultSet::cancel()
766 throw(RuntimeException
, std::exception
)
768 OSL_TRACE("OResultSet::cancel");
769 MutexGuard
aGuard(m_aMutex
);
770 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
773 void SAL_CALL
OResultSet::clearWarnings()
774 throw(SQLException
, RuntimeException
, std::exception
)
776 OSL_TRACE("OResultSet::clearWarnings");
779 Any SAL_CALL
OResultSet::getWarnings()
780 throw(SQLException
, RuntimeException
, std::exception
)
782 OSL_TRACE("OResultSet::getWarnings");
787 void SAL_CALL
OResultSet::insertRow()
788 throw(SQLException
, RuntimeException
, std::exception
)
790 OSL_TRACE("OResultSet::insertRow");
791 MutexGuard
aGuard(m_aMutex
);
792 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
793 // you only have to implement this if you want to insert new rows
794 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::insertRow", *this);
797 void SAL_CALL
OResultSet::updateRow()
798 throw(SQLException
, RuntimeException
, std::exception
)
800 OSL_TRACE("OResultSet::updateRow");
801 MutexGuard
aGuard(m_aMutex
);
802 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
804 // only when you allow updates
805 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateRow", *this);
808 void SAL_CALL
OResultSet::deleteRow()
809 throw(SQLException
, RuntimeException
, std::exception
)
811 OSL_TRACE("OResultSet::deleteRow");
812 MutexGuard
aGuard(m_aMutex
);
813 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
814 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::deleteRow", *this);
817 void SAL_CALL
OResultSet::cancelRowUpdates()
818 throw(SQLException
, RuntimeException
, std::exception
)
820 OSL_TRACE("OResultSet::cancelRowUpdates");
821 MutexGuard
aGuard(m_aMutex
);
822 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
823 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::cancelRowUpdates", *this);
826 void SAL_CALL
OResultSet::moveToInsertRow()
827 throw(SQLException
, RuntimeException
, std::exception
)
829 OSL_TRACE("OResultSet::moveToInsertRow");
830 MutexGuard
aGuard(m_aMutex
);
831 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
833 // only when you allow insert's
834 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::moveToInsertRow", *this);
837 void SAL_CALL
OResultSet::moveToCurrentRow()
838 throw(SQLException
, RuntimeException
, std::exception
)
840 OSL_TRACE("OResultSet::moveToCurrentRow");
841 MutexGuard
aGuard(m_aMutex
);
842 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
845 void SAL_CALL
OResultSet::updateNull(sal_Int32 column
)
846 throw(SQLException
, RuntimeException
, std::exception
)
848 OSL_TRACE("OResultSet::updateNull");
849 MutexGuard
aGuard(m_aMutex
);
850 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
851 checkColumnIndex(column
);
852 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateNull", *this);
855 void SAL_CALL
OResultSet::updateBoolean(sal_Int32 column
, sal_Bool
/* x */)
856 throw(SQLException
, RuntimeException
, std::exception
)
858 OSL_TRACE("OResultSet::updateBoolean");
859 MutexGuard
aGuard(m_aMutex
);
860 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
861 checkColumnIndex(column
);
862 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateBoolean", *this);
865 void SAL_CALL
OResultSet::updateByte(sal_Int32 column
, sal_Int8
/* x */)
866 throw(SQLException
, RuntimeException
, std::exception
)
868 OSL_TRACE("OResultSet::updateByte");
869 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
870 MutexGuard
aGuard(m_aMutex
);
871 checkColumnIndex(column
);
872 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateByte", *this);
875 void SAL_CALL
OResultSet::updateShort(sal_Int32 column
, sal_Int16
/* x */)
876 throw(SQLException
, RuntimeException
, std::exception
)
878 OSL_TRACE("OResultSet::updateShort");
879 MutexGuard
aGuard(m_aMutex
);
880 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
881 checkColumnIndex(column
);
882 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateShort", *this);
885 void SAL_CALL
OResultSet::updateInt(sal_Int32 column
, sal_Int32
/* x */)
886 throw(SQLException
, RuntimeException
, std::exception
)
888 OSL_TRACE("OResultSet::updateInt");
889 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
890 MutexGuard
aGuard(m_aMutex
);
891 checkColumnIndex(column
);
892 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateInt", *this);
895 void SAL_CALL
OResultSet::updateLong(sal_Int32 column
, sal_Int64
/* x */)
896 throw(SQLException
, RuntimeException
, std::exception
)
898 OSL_TRACE("OResultSet::updateLong");
899 MutexGuard
aGuard(m_aMutex
);
900 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
901 checkColumnIndex(column
);
902 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateLong", *this);
905 void SAL_CALL
OResultSet::updateFloat(sal_Int32 column
, float /* x */)
906 throw(SQLException
, RuntimeException
, std::exception
)
908 OSL_TRACE("OResultSet::updateFloat");
909 MutexGuard
aGuard(m_aMutex
);
910 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
911 checkColumnIndex(column
);
912 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateFloat", *this);
915 void SAL_CALL
OResultSet::updateDouble(sal_Int32 column
, double /* x */)
916 throw(SQLException
, RuntimeException
, std::exception
)
918 OSL_TRACE("OResultSet::updateDouble");
919 MutexGuard
aGuard(m_aMutex
);
920 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
921 checkColumnIndex(column
);
922 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateDouble", *this);
925 void SAL_CALL
OResultSet::updateString(sal_Int32 column
, const rtl::OUString
& /* x */)
926 throw(SQLException
, RuntimeException
, std::exception
)
928 OSL_TRACE("OResultSet::updateString");
929 MutexGuard
aGuard(m_aMutex
);
930 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
931 checkColumnIndex(column
);
932 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateString", *this);
935 void SAL_CALL
OResultSet::updateBytes(sal_Int32 column
, const Sequence
< sal_Int8
>& /* x */)
936 throw(SQLException
, RuntimeException
, std::exception
)
938 OSL_TRACE("OResultSet::updateBytes");
939 MutexGuard
aGuard(m_aMutex
);
940 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
941 checkColumnIndex(column
);
942 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateBytes", *this);
945 void SAL_CALL
OResultSet::updateDate(sal_Int32 column
, const Date
& /* x */)
946 throw(SQLException
, RuntimeException
, std::exception
)
948 OSL_TRACE("OResultSet::updateDate");
949 MutexGuard
aGuard(m_aMutex
);
950 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
951 checkColumnIndex(column
);
952 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateDate", *this);
955 void SAL_CALL
OResultSet::updateTime(sal_Int32 column
, const Time
& /* x */)
956 throw(SQLException
, RuntimeException
, std::exception
)
958 OSL_TRACE("OResultSet::updateTime");
959 MutexGuard
aGuard(m_aMutex
);
960 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
961 checkColumnIndex(column
);
962 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateTime", *this);
965 void SAL_CALL
OResultSet::updateTimestamp(sal_Int32 column
, const DateTime
& /* x */)
966 throw(SQLException
, RuntimeException
, std::exception
)
968 OSL_TRACE("OResultSet::updateTimestamp");
969 MutexGuard
aGuard(m_aMutex
);
970 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
971 checkColumnIndex(column
);
972 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateTimestamp", *this);
975 void SAL_CALL
OResultSet::updateBinaryStream(sal_Int32 column
, const Reference
< XInputStream
>& /* x */,
976 sal_Int32
/* length */)
977 throw(SQLException
, RuntimeException
, std::exception
)
979 OSL_TRACE("OResultSet::updateBinaryStream");
980 MutexGuard
aGuard(m_aMutex
);
981 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
982 checkColumnIndex(column
);
983 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateBinaryStream", *this);
986 void SAL_CALL
OResultSet::updateCharacterStream(sal_Int32 column
, const Reference
< XInputStream
>& /* x */,
987 sal_Int32
/* length */)
988 throw(SQLException
, RuntimeException
, std::exception
)
990 OSL_TRACE("OResultSet::updateCharacterStream");
991 MutexGuard
aGuard(m_aMutex
);
992 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
993 checkColumnIndex(column
);
994 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateCharacterStream", *this);
997 void SAL_CALL
OResultSet::refreshRow()
998 throw(SQLException
, RuntimeException
, std::exception
)
1000 OSL_TRACE("OResultSet::refreshRow");
1001 MutexGuard
aGuard(m_aMutex
);
1002 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
1003 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::refreshRow", *this);
1006 void SAL_CALL
OResultSet::updateObject(sal_Int32 column
, const Any
& /* x */)
1007 throw(SQLException
, RuntimeException
, std::exception
)
1009 OSL_TRACE("OResultSet::updateObject");
1010 MutexGuard
aGuard(m_aMutex
);
1011 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
1012 checkColumnIndex(column
);
1013 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateObject", *this);
1016 void SAL_CALL
OResultSet::updateNumericObject(sal_Int32 column
, const Any
& /* x */, sal_Int32
/* scale */)
1017 throw(SQLException
, RuntimeException
, std::exception
)
1019 OSL_TRACE("OResultSet::updateNumericObject");
1020 MutexGuard
aGuard(m_aMutex
);
1021 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
1022 checkColumnIndex(column
);
1023 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateNumericObject", *this);
1027 Any SAL_CALL
OResultSet::getBookmark()
1028 throw(SQLException
, RuntimeException
, std::exception
)
1030 OSL_TRACE("OResultSet::getBookmark");
1031 MutexGuard
aGuard(m_aMutex
);
1032 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
1035 // if you don't want to support bookmark you must remove the XRowLocate interface
1036 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getBookmark", *this);
1041 sal_Bool SAL_CALL
OResultSet::moveToBookmark(const Any
& /* bookmark */)
1042 throw(SQLException
, RuntimeException
, std::exception
)
1044 OSL_TRACE("OResultSet::moveToBookmark");
1045 MutexGuard
aGuard(m_aMutex
);
1046 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
1051 sal_Bool SAL_CALL
OResultSet::moveRelativeToBookmark(const Any
& /* bookmark */, sal_Int32
/* rows */)
1052 throw(SQLException
, RuntimeException
, std::exception
)
1054 OSL_TRACE("OResultSet::moveRelativeToBookmark");
1055 MutexGuard
aGuard(m_aMutex
);
1056 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
1058 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::moveRelativeToBookmark", *this);
1062 sal_Int32 SAL_CALL
OResultSet::compareBookmarks(const Any
& /* n1 */, const Any
& /* n2 */)
1063 throw(SQLException
, RuntimeException
, std::exception
)
1065 OSL_TRACE("OResultSet::compareBookmarks");
1066 MutexGuard
aGuard(m_aMutex
);
1067 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
1069 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::compareBookmarks", *this);
1071 return CompareBookmark::NOT_EQUAL
;
1074 sal_Bool SAL_CALL
OResultSet::hasOrderedBookmarks()
1075 throw(SQLException
, RuntimeException
, std::exception
)
1077 OSL_TRACE("OResultSet::hasOrderedBookmarks");
1081 sal_Int32 SAL_CALL
OResultSet::hashBookmark(const Any
& /* bookmark */)
1082 throw(SQLException
, RuntimeException
, std::exception
)
1084 OSL_TRACE("OResultSet::hashBookmark");
1085 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::hashBookmark", *this);
1090 Sequence
< sal_Int32
> SAL_CALL
OResultSet::deleteRows(const Sequence
< Any
>& /* rows */)
1091 throw(SQLException
, RuntimeException
, std::exception
)
1093 OSL_TRACE("OResultSet::deleteRows");
1094 MutexGuard
aGuard(m_aMutex
);
1095 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
1096 Sequence
< sal_Int32
> aRet
= Sequence
< sal_Int32
>();
1098 mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::deleteRows", *this);
1102 IPropertyArrayHelper
* OResultSet::createArrayHelper() const
1104 OSL_TRACE("OResultSet::createArrayHelper");
1105 Sequence
< Property
> aProps(5);
1106 Property
* pProperties
= aProps
.getArray();
1108 pProperties
[nPos
++] = Property("FetchDirection", PROPERTY_ID_FETCHDIRECTION
, cppu::UnoType
<sal_Int32
>::get(), 0);
1109 pProperties
[nPos
++] = Property("FetchSize", PROPERTY_ID_FETCHSIZE
, cppu::UnoType
<sal_Int32
>::get(), 0);
1110 pProperties
[nPos
++] = Property("IsBookmarkable",
1111 PROPERTY_ID_ISBOOKMARKABLE
, cppu::UnoType
<bool>::get(), PropertyAttribute::READONLY
);
1112 pProperties
[nPos
++] = Property("ResultSetConcurrency",
1113 PROPERTY_ID_RESULTSETCONCURRENCY
, cppu::UnoType
<sal_Int32
>::get(), PropertyAttribute::READONLY
);
1114 pProperties
[nPos
++] = Property("ResultSetType",
1115 PROPERTY_ID_RESULTSETTYPE
, cppu::UnoType
<sal_Int32
>::get(), PropertyAttribute::READONLY
);
1117 return new OPropertyArrayHelper(aProps
);
1120 IPropertyArrayHelper
& OResultSet::getInfoHelper()
1122 OSL_TRACE("OResultSet::getInfoHelper");
1123 return *getArrayHelper();
1126 sal_Bool
OResultSet::convertFastPropertyValue(Any
& /* rConvertedValue */,
1127 Any
& /* rOldValue */,
1129 const Any
& /* rValue */)
1130 throw (::com::sun::star::lang::IllegalArgumentException
)
1132 OSL_TRACE("OResultSet::convertFastPropertyValue");
1134 case PROPERTY_ID_ISBOOKMARKABLE
:
1135 case PROPERTY_ID_CURSORNAME
:
1136 case PROPERTY_ID_RESULTSETCONCURRENCY
:
1137 case PROPERTY_ID_RESULTSETTYPE
:
1138 throw ::com::sun::star::lang::IllegalArgumentException();
1139 case PROPERTY_ID_FETCHDIRECTION
:
1140 case PROPERTY_ID_FETCHSIZE
:
1147 void OResultSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle
, const Any
& /* rValue */)
1148 throw (Exception
, std::exception
)
1150 OSL_TRACE("OResultSet::setFastPropertyValue_NoBroadcast");
1152 case PROPERTY_ID_ISBOOKMARKABLE
:
1153 case PROPERTY_ID_CURSORNAME
:
1154 case PROPERTY_ID_RESULTSETCONCURRENCY
:
1155 case PROPERTY_ID_RESULTSETTYPE
:
1157 case PROPERTY_ID_FETCHDIRECTION
:
1159 case PROPERTY_ID_FETCHSIZE
:
1166 void OResultSet::getFastPropertyValue(Any
& _rValue
, sal_Int32 nHandle
) const
1168 OSL_TRACE("OResultSet::getFastPropertyValue");
1170 case PROPERTY_ID_ISBOOKMARKABLE
:
1171 _rValue
<<= sal_False
;
1173 case PROPERTY_ID_CURSORNAME
:
1175 case PROPERTY_ID_RESULTSETCONCURRENCY
:
1176 _rValue
<<= ResultSetConcurrency::READ_ONLY
;
1178 case PROPERTY_ID_RESULTSETTYPE
:
1179 _rValue
<<= ResultSetType::SCROLL_INSENSITIVE
;
1181 case PROPERTY_ID_FETCHDIRECTION
:
1182 _rValue
<<= FetchDirection::FORWARD
;
1184 case PROPERTY_ID_FETCHSIZE
:
1185 _rValue
<<= sal_Int32(50);
1193 void SAL_CALL
OResultSet::acquire()
1196 OSL_TRACE("OResultSet::acquire");
1197 OResultSet_BASE::acquire();
1200 void SAL_CALL
OResultSet::release()
1203 OSL_TRACE("OResultSet::release");
1204 OResultSet_BASE::release();
1207 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
OResultSet::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException
, std::exception
)
1209 OSL_TRACE("OResultSet::getPropertySetInfo");
1210 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
1213 void OResultSet::checkColumnIndex(sal_Int32 index
)
1214 throw (SQLException
, RuntimeException
)
1216 OSL_TRACE("OResultSet::checkColumnIndex");
1217 if ((index
< 1 || index
> (int) fieldCount
)) {
1218 /* static object for efficiency or thread safety is a problem ? */
1219 rtl::OUString
buf( "index out of range" );
1220 throw SQLException(buf
, *this, rtl::OUString(), 1, Any());
1229 * vim600: noet sw=4 ts=4 fdm=marker
1230 * vim<600: noet sw=4 ts=4
1233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */