1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "NPreparedStatement.hxx"
#include <connectivity/dbexception.hxx>
#include <connectivity/dbtools.hxx>
#include <tools/diagnose_ex.h>
#include <strings.hrc>
using namespace connectivity::evoab;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::container;
using namespace com::sun::star::io;
using namespace com::sun::star::util;
IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbcx.evoab.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
OEvoabPreparedStatement::OEvoabPreparedStatement( OEvoabConnection* _pConnection )
:OCommonStatement(_pConnection)
,m_sSqlStatement()
,m_xMetaData()
{
}
void OEvoabPreparedStatement::construct( const OUString& _sql )
{
m_sSqlStatement = _sql;
m_aQueryData = impl_getEBookQuery_throw( m_sSqlStatement );
ENSURE_OR_THROW( m_aQueryData.getQuery(), "no EBookQuery" );
ENSURE_OR_THROW( m_aQueryData.xSelectColumns.is(), "no SelectColumn" );
// create our meta data
OEvoabResultSetMetaData* pMeta = new OEvoabResultSetMetaData( m_aQueryData.sTable );
m_xMetaData = pMeta;
pMeta->setEvoabFields( m_aQueryData.xSelectColumns );
}
OEvoabPreparedStatement::~OEvoabPreparedStatement()
{
}
void SAL_CALL OEvoabPreparedStatement::acquire() throw()
{
OCommonStatement::acquire();
}
void SAL_CALL OEvoabPreparedStatement::release() throw()
{
OCommonStatement::release();
}
Any SAL_CALL OEvoabPreparedStatement::queryInterface( const Type & rType )
{
Any aRet = OCommonStatement::queryInterface(rType);
if(!aRet.hasValue())
aRet = OPreparedStatement_BASE::queryInterface(rType);
return aRet;
}
Sequence< Type > SAL_CALL OEvoabPreparedStatement::getTypes( )
{
return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes());
}
Reference< XResultSetMetaData > SAL_CALL OEvoabPreparedStatement::getMetaData( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
// the meta data should have been created at construction time
ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" );
return m_xMetaData;
}
void SAL_CALL OEvoabPreparedStatement::close( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
free_column_resources();
// Reset last warning message
try {
clearWarnings ();
OCommonStatement::close();
}
catch (SQLException &) {
// If we get an error, ignore
}
}
sal_Bool SAL_CALL OEvoabPreparedStatement::execute( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
Reference< XResultSet> xRS = impl_executeQuery_throw( m_aQueryData );
return xRS.is();
}
sal_Int32 SAL_CALL OEvoabPreparedStatement::executeUpdate( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
::dbtools::throwFeatureNotImplementedSQLException( "XStatement::executeUpdate", *this );
return 0;
}
void SAL_CALL OEvoabPreparedStatement::setString( sal_Int32 /*parameterIndex*/, const OUString& /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setString", *this );
}
Reference< XConnection > SAL_CALL OEvoabPreparedStatement::getConnection( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
return impl_getConnection();
}
Reference< XResultSet > SAL_CALL OEvoabPreparedStatement::executeQuery( )
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
return impl_executeQuery_throw( m_aQueryData );
}
void SAL_CALL OEvoabPreparedStatement::setBoolean( sal_Int32 /*parameterIndex*/, sal_Bool /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBoolean", *this );
}
void SAL_CALL OEvoabPreparedStatement::setByte( sal_Int32 /*parameterIndex*/, sal_Int8 /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setByte", *this );
}
void SAL_CALL OEvoabPreparedStatement::setDate( sal_Int32 /*parameterIndex*/, const Date& /*aData*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setDate", *this );
}
void SAL_CALL OEvoabPreparedStatement::setTime( sal_Int32 /*parameterIndex*/, const css::util::Time& /*aVal*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setTime", *this );
}
void SAL_CALL OEvoabPreparedStatement::setTimestamp( sal_Int32 /*parameterIndex*/, const DateTime& /*aVal*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setTimestamp", *this );
}
void SAL_CALL OEvoabPreparedStatement::setDouble( sal_Int32 /*parameterIndex*/, double /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setDouble", *this );
}
void SAL_CALL OEvoabPreparedStatement::setFloat( sal_Int32 /*parameterIndex*/, float /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setFloat", *this );
}
void SAL_CALL OEvoabPreparedStatement::setInt( sal_Int32 /*parameterIndex*/, sal_Int32 /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setInt", *this );
}
void SAL_CALL OEvoabPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setLong", *this );
}
void SAL_CALL OEvoabPreparedStatement::setNull( sal_Int32 /*parameterIndex*/, sal_Int32 /*sqlType*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setNull", *this );
}
void SAL_CALL OEvoabPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setClob", *this );
}
void SAL_CALL OEvoabPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBlob", *this );
}
void SAL_CALL OEvoabPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setArray", *this );
}
void SAL_CALL OEvoabPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setRef", *this );
}
void SAL_CALL OEvoabPreparedStatement::setObjectWithInfo( sal_Int32 /*parameterIndex*/, const Any& /*x*/, sal_Int32 /*sqlType*/, sal_Int32 /*scale*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setObjectWithInfo", *this );
}
void SAL_CALL OEvoabPreparedStatement::setObjectNull( sal_Int32 /*parameterIndex*/, sal_Int32 /*sqlType*/, const OUString& /*typeName*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setObjectNull", *this );
}
void SAL_CALL OEvoabPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x )
{
if(!::dbtools::implSetObject(this,parameterIndex,x))
{
const OUString sError( getOwnConnection()->getResources().getResourceStringWithSubstitution(
STR_UNKNOWN_PARA_TYPE,
"$position$", OUString::number(parameterIndex)
) );
::dbtools::throwGenericSQLException(sError,*this);
}
}
void SAL_CALL OEvoabPreparedStatement::setShort( sal_Int32 /*parameterIndex*/, sal_Int16 /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setShort", *this );
}
void SAL_CALL OEvoabPreparedStatement::setBytes( sal_Int32 /*parameterIndex*/, const Sequence< sal_Int8 >& /*x*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBytes", *this );
}
void SAL_CALL OEvoabPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setCharacterStream", *this );
}
void SAL_CALL OEvoabPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ )
{
::dbtools::throwFunctionNotSupportedSQLException( "XParameters::setBinaryStream", *this );
}
void SAL_CALL OEvoabPreparedStatement::clearParameters( )
{
}
Reference< XResultSet > SAL_CALL OEvoabPreparedStatement::getResultSet( )
{
return nullptr;
}
sal_Int32 SAL_CALL OEvoabPreparedStatement::getUpdateCount( )
{
return 0;
}
sal_Bool SAL_CALL OEvoabPreparedStatement::getMoreResults( )
{
return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|