LibreOffice Module connectivity (master) 1
NPreparedStatement.cxx
Go to the documentation of this file.
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
24#include <rtl/ref.hxx>
26
27#include <strings.hrc>
28
29using namespace connectivity::evoab;
30using namespace com::sun::star::uno;
31using namespace com::sun::star::lang;
32using namespace com::sun::star::beans;
33using namespace com::sun::star::sdbc;
34using namespace com::sun::star::container;
35using namespace com::sun::star::io;
36using namespace com::sun::star::util;
37
38IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbcx.evoab.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
39
40
41OEvoabPreparedStatement::OEvoabPreparedStatement( OEvoabConnection* _pConnection )
42 :OCommonStatement(_pConnection)
43{
44}
45
46
47void OEvoabPreparedStatement::construct( const OUString& _sql )
48{
49 m_sSqlStatement = _sql;
50
52 ENSURE_OR_THROW( m_aQueryData.getQuery(), "no EBookQuery" );
53 ENSURE_OR_THROW( m_aQueryData.xSelectColumns.is(), "no SelectColumn" );
54
55 // create our meta data
58 m_xMetaData = pMeta;
59 pMeta->setEvoabFields( m_aQueryData.xSelectColumns );
60}
61
62
64{
65}
66
67
68void SAL_CALL OEvoabPreparedStatement::acquire() noexcept
69{
71}
72
73
74void SAL_CALL OEvoabPreparedStatement::release() noexcept
75{
77}
78
79
81{
83 if(!aRet.hasValue())
85 return aRet;
86}
87
89{
90 return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes());
91}
92
93
95{
96 ::osl::MutexGuard aGuard( m_aMutex );
97 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
98
99 // the meta data should have been created at construction time
100 ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" );
101 return m_xMetaData;
102}
103
104
106{
107 ::osl::MutexGuard aGuard( m_aMutex );
108 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
109
111 // Reset last warning message
112 try {
113 clearWarnings ();
115 }
116 catch (SQLException &) {
117 // If we get an error, ignore
118 }
119
120}
121
122
124{
125 ::osl::MutexGuard aGuard( m_aMutex );
126 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
127
129 return xRS.is();
130}
131
132
134{
135 ::osl::MutexGuard aGuard( m_aMutex );
136 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
137 ::dbtools::throwFeatureNotImplementedSQLException( "XStatement::executeUpdate", *this );
138 return 0;
139}
140
141
142void SAL_CALL OEvoabPreparedStatement::setString( sal_Int32 /*parameterIndex*/, const OUString& /*x*/ )
143{
144 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setString", *this );
145}
146
147
149{
150 ::osl::MutexGuard aGuard( m_aMutex );
151 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
152
153 return impl_getConnection();
154}
155
156
158{
159 ::osl::MutexGuard aGuard( m_aMutex );
160 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
161
163}
164
165
166void SAL_CALL OEvoabPreparedStatement::setBoolean( sal_Int32 /*parameterIndex*/, sal_Bool /*x*/ )
167{
168 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBoolean", *this );
169
170}
171
172void SAL_CALL OEvoabPreparedStatement::setByte( sal_Int32 /*parameterIndex*/, sal_Int8 /*x*/ )
173{
174 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setByte", *this );
175}
176
177
178void SAL_CALL OEvoabPreparedStatement::setDate( sal_Int32 /*parameterIndex*/, const Date& /*aData*/ )
179{
180 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setDate", *this );
181}
182
183
184void SAL_CALL OEvoabPreparedStatement::setTime( sal_Int32 /*parameterIndex*/, const css::util::Time& /*aVal*/ )
185{
186 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setTime", *this );
187}
188
189
190void SAL_CALL OEvoabPreparedStatement::setTimestamp( sal_Int32 /*parameterIndex*/, const DateTime& /*aVal*/ )
191{
192 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setTimestamp", *this );
193}
194
195
196void SAL_CALL OEvoabPreparedStatement::setDouble( sal_Int32 /*parameterIndex*/, double /*x*/ )
197{
198 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setDouble", *this );
199}
200
201
202void SAL_CALL OEvoabPreparedStatement::setFloat( sal_Int32 /*parameterIndex*/, float /*x*/ )
203{
204 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setFloat", *this );
205}
206
207
208void SAL_CALL OEvoabPreparedStatement::setInt( sal_Int32 /*parameterIndex*/, sal_Int32 /*x*/ )
209{
210 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setInt", *this );
211}
212
213
214void SAL_CALL OEvoabPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ )
215{
216 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setLong", *this );
217}
218
219
220void SAL_CALL OEvoabPreparedStatement::setNull( sal_Int32 /*parameterIndex*/, sal_Int32 /*sqlType*/ )
221{
222 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setNull", *this );
223}
224
225
226void SAL_CALL OEvoabPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ )
227{
228 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setClob", *this );
229}
230
231
232void SAL_CALL OEvoabPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ )
233{
234 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBlob", *this );
235}
236
237
238void SAL_CALL OEvoabPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ )
239{
240 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setArray", *this );
241}
242
243
244void SAL_CALL OEvoabPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ )
245{
246 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setRef", *this );
247}
248
249
250void SAL_CALL OEvoabPreparedStatement::setObjectWithInfo( sal_Int32 /*parameterIndex*/, const Any& /*x*/, sal_Int32 /*sqlType*/, sal_Int32 /*scale*/ )
251{
252 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setObjectWithInfo", *this );
253}
254
255
256void SAL_CALL OEvoabPreparedStatement::setObjectNull( sal_Int32 /*parameterIndex*/, sal_Int32 /*sqlType*/, const OUString& /*typeName*/ )
257{
258 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setObjectNull", *this );
259}
260
261
262void SAL_CALL OEvoabPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x )
263{
264 if(!::dbtools::implSetObject(this,parameterIndex,x))
265 {
266 const OUString sError( getOwnConnection()->getResources().getResourceStringWithSubstitution(
267 STR_UNKNOWN_PARA_TYPE,
268 "$position$", OUString::number(parameterIndex)
269 ) );
271 }
272}
273
274
275void SAL_CALL OEvoabPreparedStatement::setShort( sal_Int32 /*parameterIndex*/, sal_Int16 /*x*/ )
276{
277 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setShort", *this );
278}
279
280
281void SAL_CALL OEvoabPreparedStatement::setBytes( sal_Int32 /*parameterIndex*/, const Sequence< sal_Int8 >& /*x*/ )
282{
283 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBytes", *this );
284}
285
286
287void SAL_CALL OEvoabPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ )
288{
289 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setCharacterStream", *this );
290}
291
292
293void SAL_CALL OEvoabPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ )
294{
295 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBinaryStream", *this );
296}
297
298
300{
301}
302
304{
305 return nullptr;
306}
307
309{
310 return 0;
311}
312
314{
315 return false;
316}
317
318
319/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbcx.evoab.PreparedStatement","com.sun.star.sdbc.PreparedStatement")
QueryData impl_getEBookQuery_throw(const OUString &_rSql)
will return the EBookQuery representing the statement WHERE condition, or throw
Definition: NStatement.cxx:587
virtual void SAL_CALL acquire() noexcept override
Definition: NStatement.cxx:576
css::uno::Reference< css::sdbc::XConnection > impl_getConnection()
Definition: NStatement.hxx:232
OEvoabConnection * getOwnConnection() const
Definition: NStatement.hxx:190
virtual void SAL_CALL close() override
Definition: NStatement.cxx:207
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: NStatement.cxx:189
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL release() noexcept override
Definition: NStatement.cxx:581
virtual void SAL_CALL clearWarnings() override
Definition: NStatement.cxx:556
css::uno::Reference< css::sdbc::XResultSet > impl_executeQuery_throw(const OUString &_rSql)
Definition: NStatement.cxx:622
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery() override
virtual void SAL_CALL setShort(sal_Int32 parameterIndex, sal_Int16 x) override
virtual void SAL_CALL setObject(sal_Int32 parameterIndex, const css::uno::Any &x) override
virtual void SAL_CALL setDate(sal_Int32 parameterIndex, const css::util::Date &x) override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet() override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
virtual void SAL_CALL setNull(sal_Int32 parameterIndex, sal_Int32 sqlType) override
virtual void SAL_CALL setBoolean(sal_Int32 parameterIndex, sal_Bool x) override
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xMetaData
virtual void SAL_CALL acquire() noexcept override
virtual sal_Bool SAL_CALL execute() override
virtual void SAL_CALL release() noexcept override
virtual void SAL_CALL setLong(sal_Int32 parameterIndex, sal_Int64 x) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL setClob(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XClob > &x) override
virtual sal_Int32 SAL_CALL getUpdateCount() override
virtual void SAL_CALL setString(sal_Int32 parameterIndex, const OUString &x) override
virtual void SAL_CALL setByte(sal_Int32 parameterIndex, sal_Int8 x) override
virtual void SAL_CALL setObjectNull(sal_Int32 parameterIndex, sal_Int32 sqlType, const OUString &typeName) override
virtual void SAL_CALL setCharacterStream(sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual void SAL_CALL setFloat(sal_Int32 parameterIndex, float x) override
virtual void SAL_CALL setBinaryStream(sal_Int32 parameterIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual void SAL_CALL setBlob(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XBlob > &x) override
virtual void SAL_CALL setTime(sal_Int32 parameterIndex, const css::util::Time &x) override
virtual void SAL_CALL setDouble(sal_Int32 parameterIndex, double x) override
virtual void SAL_CALL clearParameters() override
virtual void SAL_CALL setInt(sal_Int32 parameterIndex, sal_Int32 x) override
virtual void SAL_CALL setTimestamp(sal_Int32 parameterIndex, const css::util::DateTime &x) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void SAL_CALL setObjectWithInfo(sal_Int32 parameterIndex, const css::uno::Any &x, sal_Int32 targetSqlType, sal_Int32 scale) override
virtual void SAL_CALL setBytes(sal_Int32 parameterIndex, const css::uno::Sequence< sal_Int8 > &x) override
virtual void SAL_CALL setArray(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XArray > &x) override
virtual sal_Int32 SAL_CALL executeUpdate() override
virtual void SAL_CALL setRef(sal_Int32 parameterIndex, const css::uno::Reference< css::sdbc::XRef > &x) override
virtual sal_Bool SAL_CALL getMoreResults() override
mutable::osl::Mutex m_aMutex
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
#define ENSURE_OR_THROW(c, m)
float x
Type
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
bool implSetObject(const Reference< XParameters > &_rxParameters, const sal_Int32 _nColumnIndex, const Any &_rValue)
Definition: dbtools.cxx:1516
void throwFeatureNotImplementedSQLException(const OUString &_rFeatureName, const Reference< XInterface > &_rxContext, const Any &_rNextException)
void throwFunctionNotSupportedSQLException(const OUString &_rFunctionName, const css::uno::Reference< css::uno::XInterface > &_rxContext)
throws an exception with SQL state IM001, saying that a certain function is not supported
void throwGenericSQLException(const OUString &_rMsg, const css::uno::Reference< css::uno::XInterface > &_rxSource)
throw a generic SQLException, i.e.
rtl::Reference< connectivity::OSQLColumns > xSelectColumns
Definition: NStatement.hxx:128
EBookQuery * getQuery() const
Definition: NStatement.hxx:139
unsigned char sal_Bool
signed char sal_Int8