Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / connectivity / source / drivers / evoab2 / NPreparedStatement.cxx
blob7738bfa4a3468ad7859e87c2d4ddfa3e0bb81590
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include "NPreparedStatement.hxx"
22 #include <connectivity/dbexception.hxx>
23 #include <connectivity/dbtools.hxx>
24 #include <rtl/ref.hxx>
25 #include <comphelper/diagnose_ex.hxx>
27 #include <strings.hrc>
29 using namespace connectivity::evoab;
30 using namespace com::sun::star::uno;
31 using namespace com::sun::star::lang;
32 using namespace com::sun::star::beans;
33 using namespace com::sun::star::sdbc;
34 using namespace com::sun::star::container;
35 using namespace com::sun::star::io;
36 using namespace com::sun::star::util;
38 IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbcx.evoab.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
41 OEvoabPreparedStatement::OEvoabPreparedStatement( OEvoabConnection* _pConnection )
42 :OCommonStatement(_pConnection)
47 void OEvoabPreparedStatement::construct( const OUString& _sql )
49 m_sSqlStatement = _sql;
51 m_aQueryData = impl_getEBookQuery_throw( m_sSqlStatement );
52 ENSURE_OR_THROW( m_aQueryData.getQuery(), "no EBookQuery" );
53 ENSURE_OR_THROW( m_aQueryData.xSelectColumns.is(), "no SelectColumn" );
55 // create our meta data
56 rtl::Reference<OEvoabResultSetMetaData> pMeta
57 = new OEvoabResultSetMetaData( m_aQueryData.sTable );
58 m_xMetaData = pMeta;
59 pMeta->setEvoabFields( m_aQueryData.xSelectColumns );
63 OEvoabPreparedStatement::~OEvoabPreparedStatement()
68 void SAL_CALL OEvoabPreparedStatement::acquire() noexcept
70 OCommonStatement::acquire();
74 void SAL_CALL OEvoabPreparedStatement::release() noexcept
76 OCommonStatement::release();
80 Any SAL_CALL OEvoabPreparedStatement::queryInterface( const Type & rType )
82 Any aRet = OCommonStatement::queryInterface(rType);
83 if(!aRet.hasValue())
84 aRet = OPreparedStatement_BASE::queryInterface(rType);
85 return aRet;
88 Sequence< Type > SAL_CALL OEvoabPreparedStatement::getTypes( )
90 return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes());
94 Reference< XResultSetMetaData > SAL_CALL OEvoabPreparedStatement::getMetaData( )
96 ::osl::MutexGuard aGuard( m_aMutex );
97 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
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;
105 void SAL_CALL OEvoabPreparedStatement::close( )
107 ::osl::MutexGuard aGuard( m_aMutex );
108 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
110 free_column_resources();
111 // Reset last warning message
112 try {
113 clearWarnings ();
114 OCommonStatement::close();
116 catch (SQLException &) {
117 // If we get an error, ignore
123 sal_Bool SAL_CALL OEvoabPreparedStatement::execute( )
125 ::osl::MutexGuard aGuard( m_aMutex );
126 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
128 Reference< XResultSet> xRS = impl_executeQuery_throw( m_aQueryData );
129 return xRS.is();
133 sal_Int32 SAL_CALL OEvoabPreparedStatement::executeUpdate( )
135 ::osl::MutexGuard aGuard( m_aMutex );
136 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
137 ::dbtools::throwFeatureNotImplementedSQLException( "XStatement::executeUpdate", *this );
138 return 0;
142 void SAL_CALL OEvoabPreparedStatement::setString( sal_Int32 /*parameterIndex*/, const OUString& /*x*/ )
144 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setString", *this );
148 Reference< XConnection > SAL_CALL OEvoabPreparedStatement::getConnection( )
150 ::osl::MutexGuard aGuard( m_aMutex );
151 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
153 return impl_getConnection();
157 Reference< XResultSet > SAL_CALL OEvoabPreparedStatement::executeQuery( )
159 ::osl::MutexGuard aGuard( m_aMutex );
160 checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
162 return impl_executeQuery_throw( m_aQueryData );
166 void SAL_CALL OEvoabPreparedStatement::setBoolean( sal_Int32 /*parameterIndex*/, sal_Bool /*x*/ )
168 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBoolean", *this );
172 void SAL_CALL OEvoabPreparedStatement::setByte( sal_Int32 /*parameterIndex*/, sal_Int8 /*x*/ )
174 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setByte", *this );
178 void SAL_CALL OEvoabPreparedStatement::setDate( sal_Int32 /*parameterIndex*/, const Date& /*aData*/ )
180 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setDate", *this );
184 void SAL_CALL OEvoabPreparedStatement::setTime( sal_Int32 /*parameterIndex*/, const css::util::Time& /*aVal*/ )
186 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setTime", *this );
190 void SAL_CALL OEvoabPreparedStatement::setTimestamp( sal_Int32 /*parameterIndex*/, const DateTime& /*aVal*/ )
192 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setTimestamp", *this );
196 void SAL_CALL OEvoabPreparedStatement::setDouble( sal_Int32 /*parameterIndex*/, double /*x*/ )
198 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setDouble", *this );
202 void SAL_CALL OEvoabPreparedStatement::setFloat( sal_Int32 /*parameterIndex*/, float /*x*/ )
204 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setFloat", *this );
208 void SAL_CALL OEvoabPreparedStatement::setInt( sal_Int32 /*parameterIndex*/, sal_Int32 /*x*/ )
210 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setInt", *this );
214 void SAL_CALL OEvoabPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ )
216 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setLong", *this );
220 void SAL_CALL OEvoabPreparedStatement::setNull( sal_Int32 /*parameterIndex*/, sal_Int32 /*sqlType*/ )
222 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setNull", *this );
226 void SAL_CALL OEvoabPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ )
228 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setClob", *this );
232 void SAL_CALL OEvoabPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ )
234 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBlob", *this );
238 void SAL_CALL OEvoabPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ )
240 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setArray", *this );
244 void SAL_CALL OEvoabPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ )
246 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setRef", *this );
250 void SAL_CALL OEvoabPreparedStatement::setObjectWithInfo( sal_Int32 /*parameterIndex*/, const Any& /*x*/, sal_Int32 /*sqlType*/, sal_Int32 /*scale*/ )
252 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setObjectWithInfo", *this );
256 void SAL_CALL OEvoabPreparedStatement::setObjectNull( sal_Int32 /*parameterIndex*/, sal_Int32 /*sqlType*/, const OUString& /*typeName*/ )
258 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setObjectNull", *this );
262 void SAL_CALL OEvoabPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x )
264 if(!::dbtools::implSetObject(this,parameterIndex,x))
266 const OUString sError( getOwnConnection()->getResources().getResourceStringWithSubstitution(
267 STR_UNKNOWN_PARA_TYPE,
268 "$position$", OUString::number(parameterIndex)
269 ) );
270 ::dbtools::throwGenericSQLException(sError,*this);
275 void SAL_CALL OEvoabPreparedStatement::setShort( sal_Int32 /*parameterIndex*/, sal_Int16 /*x*/ )
277 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setShort", *this );
281 void SAL_CALL OEvoabPreparedStatement::setBytes( sal_Int32 /*parameterIndex*/, const Sequence< sal_Int8 >& /*x*/ )
283 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBytes", *this );
287 void SAL_CALL OEvoabPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ )
289 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setCharacterStream", *this );
293 void SAL_CALL OEvoabPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ )
295 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBinaryStream", *this );
299 void SAL_CALL OEvoabPreparedStatement::clearParameters( )
303 Reference< XResultSet > SAL_CALL OEvoabPreparedStatement::getResultSet( )
305 return nullptr;
308 sal_Int32 SAL_CALL OEvoabPreparedStatement::getUpdateCount( )
310 return 0;
313 sal_Bool SAL_CALL OEvoabPreparedStatement::getMoreResults( )
315 return false;
319 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */