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 .
21 #include "NPreparedStatement.hxx"
22 #include <connectivity/dbexception.hxx>
23 #include <connectivity/dbtools.hxx>
24 #include <rtl/ref.hxx>
25 #include <tools/diagnose_ex.h>
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
)
49 void OEvoabPreparedStatement::construct( const OUString
& _sql
)
51 m_sSqlStatement
= _sql
;
53 m_aQueryData
= impl_getEBookQuery_throw( m_sSqlStatement
);
54 ENSURE_OR_THROW( m_aQueryData
.getQuery(), "no EBookQuery" );
55 ENSURE_OR_THROW( m_aQueryData
.xSelectColumns
.is(), "no SelectColumn" );
57 // create our meta data
58 rtl::Reference
<OEvoabResultSetMetaData
> pMeta
59 = new OEvoabResultSetMetaData( m_aQueryData
.sTable
);
61 pMeta
->setEvoabFields( m_aQueryData
.xSelectColumns
);
65 OEvoabPreparedStatement::~OEvoabPreparedStatement()
70 void SAL_CALL
OEvoabPreparedStatement::acquire() noexcept
72 OCommonStatement::acquire();
76 void SAL_CALL
OEvoabPreparedStatement::release() noexcept
78 OCommonStatement::release();
82 Any SAL_CALL
OEvoabPreparedStatement::queryInterface( const Type
& rType
)
84 Any aRet
= OCommonStatement::queryInterface(rType
);
86 aRet
= OPreparedStatement_BASE::queryInterface(rType
);
90 Sequence
< Type
> SAL_CALL
OEvoabPreparedStatement::getTypes( )
92 return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes());
96 Reference
< XResultSetMetaData
> SAL_CALL
OEvoabPreparedStatement::getMetaData( )
98 ::osl::MutexGuard
aGuard( m_aMutex
);
99 checkDisposed(OCommonStatement_IBase::rBHelper
.bDisposed
);
101 // the meta data should have been created at construction time
102 ENSURE_OR_THROW( m_xMetaData
.is(), "internal error: no meta data" );
107 void SAL_CALL
OEvoabPreparedStatement::close( )
109 ::osl::MutexGuard
aGuard( m_aMutex
);
110 checkDisposed(OCommonStatement_IBase::rBHelper
.bDisposed
);
112 free_column_resources();
113 // Reset last warning message
116 OCommonStatement::close();
118 catch (SQLException
&) {
119 // If we get an error, ignore
125 sal_Bool SAL_CALL
OEvoabPreparedStatement::execute( )
127 ::osl::MutexGuard
aGuard( m_aMutex
);
128 checkDisposed(OCommonStatement_IBase::rBHelper
.bDisposed
);
130 Reference
< XResultSet
> xRS
= impl_executeQuery_throw( m_aQueryData
);
135 sal_Int32 SAL_CALL
OEvoabPreparedStatement::executeUpdate( )
137 ::osl::MutexGuard
aGuard( m_aMutex
);
138 checkDisposed(OCommonStatement_IBase::rBHelper
.bDisposed
);
139 ::dbtools::throwFeatureNotImplementedSQLException( "XStatement::executeUpdate", *this );
144 void SAL_CALL
OEvoabPreparedStatement::setString( sal_Int32
/*parameterIndex*/, const OUString
& /*x*/ )
146 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setString", *this );
150 Reference
< XConnection
> SAL_CALL
OEvoabPreparedStatement::getConnection( )
152 ::osl::MutexGuard
aGuard( m_aMutex
);
153 checkDisposed(OCommonStatement_IBase::rBHelper
.bDisposed
);
155 return impl_getConnection();
159 Reference
< XResultSet
> SAL_CALL
OEvoabPreparedStatement::executeQuery( )
161 ::osl::MutexGuard
aGuard( m_aMutex
);
162 checkDisposed(OCommonStatement_IBase::rBHelper
.bDisposed
);
164 return impl_executeQuery_throw( m_aQueryData
);
168 void SAL_CALL
OEvoabPreparedStatement::setBoolean( sal_Int32
/*parameterIndex*/, sal_Bool
/*x*/ )
170 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBoolean", *this );
174 void SAL_CALL
OEvoabPreparedStatement::setByte( sal_Int32
/*parameterIndex*/, sal_Int8
/*x*/ )
176 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setByte", *this );
180 void SAL_CALL
OEvoabPreparedStatement::setDate( sal_Int32
/*parameterIndex*/, const Date
& /*aData*/ )
182 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setDate", *this );
186 void SAL_CALL
OEvoabPreparedStatement::setTime( sal_Int32
/*parameterIndex*/, const css::util::Time
& /*aVal*/ )
188 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setTime", *this );
192 void SAL_CALL
OEvoabPreparedStatement::setTimestamp( sal_Int32
/*parameterIndex*/, const DateTime
& /*aVal*/ )
194 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setTimestamp", *this );
198 void SAL_CALL
OEvoabPreparedStatement::setDouble( sal_Int32
/*parameterIndex*/, double /*x*/ )
200 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setDouble", *this );
204 void SAL_CALL
OEvoabPreparedStatement::setFloat( sal_Int32
/*parameterIndex*/, float /*x*/ )
206 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setFloat", *this );
210 void SAL_CALL
OEvoabPreparedStatement::setInt( sal_Int32
/*parameterIndex*/, sal_Int32
/*x*/ )
212 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setInt", *this );
216 void SAL_CALL
OEvoabPreparedStatement::setLong( sal_Int32
/*parameterIndex*/, sal_Int64
/*aVal*/ )
218 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setLong", *this );
222 void SAL_CALL
OEvoabPreparedStatement::setNull( sal_Int32
/*parameterIndex*/, sal_Int32
/*sqlType*/ )
224 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setNull", *this );
228 void SAL_CALL
OEvoabPreparedStatement::setClob( sal_Int32
/*parameterIndex*/, const Reference
< XClob
>& /*x*/ )
230 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setClob", *this );
234 void SAL_CALL
OEvoabPreparedStatement::setBlob( sal_Int32
/*parameterIndex*/, const Reference
< XBlob
>& /*x*/ )
236 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBlob", *this );
240 void SAL_CALL
OEvoabPreparedStatement::setArray( sal_Int32
/*parameterIndex*/, const Reference
< XArray
>& /*x*/ )
242 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setArray", *this );
246 void SAL_CALL
OEvoabPreparedStatement::setRef( sal_Int32
/*parameterIndex*/, const Reference
< XRef
>& /*x*/ )
248 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setRef", *this );
252 void SAL_CALL
OEvoabPreparedStatement::setObjectWithInfo( sal_Int32
/*parameterIndex*/, const Any
& /*x*/, sal_Int32
/*sqlType*/, sal_Int32
/*scale*/ )
254 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setObjectWithInfo", *this );
258 void SAL_CALL
OEvoabPreparedStatement::setObjectNull( sal_Int32
/*parameterIndex*/, sal_Int32
/*sqlType*/, const OUString
& /*typeName*/ )
260 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setObjectNull", *this );
264 void SAL_CALL
OEvoabPreparedStatement::setObject( sal_Int32 parameterIndex
, const Any
& x
)
266 if(!::dbtools::implSetObject(this,parameterIndex
,x
))
268 const OUString
sError( getOwnConnection()->getResources().getResourceStringWithSubstitution(
269 STR_UNKNOWN_PARA_TYPE
,
270 "$position$", OUString::number(parameterIndex
)
272 ::dbtools::throwGenericSQLException(sError
,*this);
277 void SAL_CALL
OEvoabPreparedStatement::setShort( sal_Int32
/*parameterIndex*/, sal_Int16
/*x*/ )
279 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setShort", *this );
283 void SAL_CALL
OEvoabPreparedStatement::setBytes( sal_Int32
/*parameterIndex*/, const Sequence
< sal_Int8
>& /*x*/ )
285 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBytes", *this );
289 void SAL_CALL
OEvoabPreparedStatement::setCharacterStream( sal_Int32
/*parameterIndex*/, const Reference
< XInputStream
>& /*x*/, sal_Int32
/*length*/ )
291 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setCharacterStream", *this );
295 void SAL_CALL
OEvoabPreparedStatement::setBinaryStream( sal_Int32
/*parameterIndex*/, const Reference
< XInputStream
>& /*x*/, sal_Int32
/*length*/ )
297 ::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBinaryStream", *this );
301 void SAL_CALL
OEvoabPreparedStatement::clearParameters( )
305 Reference
< XResultSet
> SAL_CALL
OEvoabPreparedStatement::getResultSet( )
310 sal_Int32 SAL_CALL
OEvoabPreparedStatement::getUpdateCount( )
315 sal_Bool SAL_CALL
OEvoabPreparedStatement::getMoreResults( )
321 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */