2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: connection.cxx,v $
|
|
|
|
*
|
2002-12-12 09:43:23 +00:00
|
|
|
* $Revision: 1.34 $
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2002-12-12 09:43:23 +00:00
|
|
|
* last change: $Author: oj $ $Date: 2002-12-12 10:43:23 $
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (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.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#ifndef _DBA_CORE_CONNECTION_HXX_
|
|
|
|
#include "connection.hxx"
|
|
|
|
#endif
|
2000-10-25 06:42:28 +00:00
|
|
|
#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
|
|
|
|
#include "dbastrings.hrc"
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _DBA_COREDATAACCESS_DATASOURCE_HXX_
|
|
|
|
#include "datasource.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_COREAPI_STATEMENT_HXX_
|
|
|
|
#include <statement.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_COREAPI_PREPAREDSTATEMENT_HXX_
|
|
|
|
#include <preparedstatement.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DBA_COREAPI_CALLABLESTATEMENT_HXX_
|
|
|
|
#include <callablestatement.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_
|
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_
|
|
|
|
#include <com/sun/star/sdbc/XDriverAccess.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
|
|
|
|
#endif
|
2002-08-12 08:21:59 +00:00
|
|
|
#ifndef _COM_SUN_STAR_REFLECTION_XPROXYFACTORY_HPP_
|
|
|
|
#include <com/sun/star/reflection/XProxyFactory.hpp>
|
|
|
|
#endif
|
2000-10-11 10:21:40 +00:00
|
|
|
#ifndef _COMPHELPER_SEQUENCE_HXX_
|
|
|
|
#include <comphelper/sequence.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
2000-10-11 10:21:40 +00:00
|
|
|
#ifndef _CONNECTIVITY_DBTOOLS_HXX_
|
|
|
|
#include <connectivity/dbtools.hxx>
|
2000-09-18 23:16:46 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
|
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
|
|
|
#endif
|
2001-03-02 16:01:04 +00:00
|
|
|
#ifndef DBACCESS_CORE_API_QUERYCOMPOSER_HXX
|
2000-09-18 23:16:46 +00:00
|
|
|
#include "querycomposer.hxx"
|
2001-03-02 16:01:04 +00:00
|
|
|
#endif
|
2001-03-15 07:29:16 +00:00
|
|
|
#ifndef _COMPHELPER_EXTRACT_HXX_
|
|
|
|
#include <comphelper/extract.hxx>
|
2001-02-14 14:04:16 +00:00
|
|
|
#endif
|
2002-08-12 08:21:59 +00:00
|
|
|
#ifndef _COMPHELPER_UNO3_HXX_
|
|
|
|
#include <comphelper/uno3.hxx>
|
|
|
|
#endif
|
2001-03-02 16:01:04 +00:00
|
|
|
#ifndef _DBHELPER_DBEXCEPTION_HXX_
|
|
|
|
#include <connectivity/dbexception.hxx>
|
|
|
|
#endif
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star::sdb;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::beans;
|
2002-08-12 08:21:59 +00:00
|
|
|
using namespace ::com::sun::star::reflection;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::com::sun::star::container;
|
|
|
|
using namespace ::osl;
|
2000-10-11 10:21:40 +00:00
|
|
|
using namespace ::comphelper;
|
2000-09-18 23:16:46 +00:00
|
|
|
using namespace ::cppu;
|
2001-03-02 16:01:04 +00:00
|
|
|
using namespace ::dbtools;
|
2001-06-18 10:50:01 +00:00
|
|
|
using namespace ::utl;
|
2000-10-18 15:16:39 +00:00
|
|
|
|
|
|
|
//........................................................................
|
|
|
|
namespace dbaccess
|
|
|
|
{
|
|
|
|
//........................................................................
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
// XServiceInfo
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
rtl::OUString OConnection::getImplementationName( ) throw(RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-08-12 08:21:59 +00:00
|
|
|
return rtl::OUString::createFromAscii("com.sun.star.comp.dbaccess.Connection");
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
sal_Bool OConnection::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return findValue(getSupportedServiceNames(), _rServiceName, sal_True).getLength() != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
Sequence< ::rtl::OUString > OConnection::getSupportedServiceNames( ) throw (RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-08-15 09:40:25 +00:00
|
|
|
Sequence< ::rtl::OUString > aSupported = OConnectionWrapper::getSupportedServiceNames();
|
|
|
|
|
|
|
|
if ( 0 == findValue( aSupported, SERVICE_SDB_CONNECTION, sal_True ).getLength() )
|
|
|
|
{
|
|
|
|
sal_Int32 nLen = aSupported.getLength();
|
|
|
|
aSupported.realloc( nLen + 1 );
|
|
|
|
aSupported[ nLen ] = SERVICE_SDB_CONNECTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aSupported;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// XCloseable
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
void OConnection::close(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-08-15 09:40:25 +00:00
|
|
|
// being closed is the same as being disposed
|
|
|
|
dispose();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
sal_Bool OConnection::isClosed(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
2002-08-12 08:21:59 +00:00
|
|
|
return !m_xConnection.is();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// XConnection
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
Reference< XStatement > OConnection::createStatement(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
|
|
|
|
2002-10-10 12:22:42 +00:00
|
|
|
Reference< XStatement > xStatement;
|
2002-08-12 08:21:59 +00:00
|
|
|
Reference< XStatement > xMasterStatement = m_xConnection->createStatement();
|
2002-10-10 12:22:42 +00:00
|
|
|
if ( xMasterStatement.is() )
|
|
|
|
{
|
|
|
|
xStatement = new OStatement(this, xMasterStatement);
|
|
|
|
m_aStatements.push_back(WeakReferenceHelper(xStatement));
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
return xStatement;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
Reference< XPreparedStatement > OConnection::prepareStatement(const rtl::OUString& sql) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
|
|
|
|
|
|
|
// TODO convert the SQL to SQL the driver understands
|
2002-10-10 12:22:42 +00:00
|
|
|
Reference< XPreparedStatement > xStatement;
|
2002-08-12 08:21:59 +00:00
|
|
|
Reference< XPreparedStatement > xMasterStatement = m_xConnection->prepareStatement(sql);
|
2002-10-10 12:22:42 +00:00
|
|
|
if ( xMasterStatement.is() )
|
|
|
|
{
|
|
|
|
xStatement = new OPreparedStatement(this, xMasterStatement);
|
|
|
|
m_aStatements.push_back(WeakReferenceHelper(xStatement));
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
return xStatement;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
Reference< XPreparedStatement > OConnection::prepareCall(const rtl::OUString& sql) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
|
|
|
|
2002-10-10 12:22:42 +00:00
|
|
|
Reference< XPreparedStatement > xStatement;
|
2000-09-18 23:16:46 +00:00
|
|
|
Reference< XPreparedStatement > xMasterStatement = prepareCall(sql);
|
2002-10-10 12:22:42 +00:00
|
|
|
if ( xMasterStatement.is() )
|
|
|
|
{
|
|
|
|
xStatement = new OCallableStatement(this, xMasterStatement);
|
|
|
|
m_aStatements.push_back(WeakReferenceHelper(xStatement));
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
return xStatement;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
rtl::OUString OConnection::nativeSQL(const rtl::OUString& sql) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
return m_xConnection->nativeSQL(sql);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
void OConnection::setAutoCommit(sal_Bool autoCommit) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
m_xConnection->setAutoCommit(autoCommit);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
sal_Bool OConnection::getAutoCommit(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
return m_xConnection->getAutoCommit();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
void OConnection::commit(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
m_xConnection->commit();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
void OConnection::rollback(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
m_xConnection->rollback();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
Reference< XDatabaseMetaData > OConnection::getMetaData(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
return m_xConnection->getMetaData();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
void OConnection::setReadOnly(sal_Bool readOnly) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
m_xConnection->setReadOnly(readOnly);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
sal_Bool OConnection::isReadOnly(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
return m_xConnection->isReadOnly();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
void OConnection::setCatalog(const rtl::OUString& catalog) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
m_xConnection->setCatalog(catalog);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
rtl::OUString OConnection::getCatalog(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
return m_xConnection->getCatalog();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
void OConnection::setTransactionIsolation(sal_Int32 level) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
m_xConnection->setTransactionIsolation(level);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
sal_Int32 OConnection::getTransactionIsolation(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
return m_xConnection->getTransactionIsolation();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
Reference< XNameAccess > OConnection::getTypeMap(void) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
return m_xConnection->getTypeMap();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
void OConnection::setTypeMap(const Reference< XNameAccess > & typeMap) throw( SQLException, RuntimeException )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
2002-08-12 08:21:59 +00:00
|
|
|
m_xConnection->setTypeMap(typeMap);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
//==========================================================================
|
|
|
|
//= OConnection
|
|
|
|
//==========================================================================
|
|
|
|
DBG_NAME(OConnection)
|
|
|
|
//--------------------------------------------------------------------------
|
2000-12-12 11:20:31 +00:00
|
|
|
OConnection::OConnection(ODatabaseSource& _rDB, const OConfigurationNode& _rTablesConfig,const OConfigurationTreeRoot& _rCommitLocation,
|
2002-08-12 08:21:59 +00:00
|
|
|
Reference< XConnection >& _rxMaster, const Reference< XMultiServiceFactory >& _rxORB)
|
|
|
|
:OSubComponent(m_aMutex, static_cast< OWeakObject* >(&_rDB))
|
2001-08-24 12:15:06 +00:00
|
|
|
,m_aQueries(*this, m_aMutex, static_cast< XNameContainer* >(&_rDB.m_aCommandDefinitions), _rDB.m_aCommandDefinitions.getConfigLocation().cloneAsRoot(), _rxORB, this)
|
2000-09-18 23:16:46 +00:00
|
|
|
// as the queries reroute their refcounting to us, this m_aMutex is okey. If the queries
|
|
|
|
// container would do it's own refcounting, it would have to aquire m_pMutex
|
|
|
|
// same for tables
|
|
|
|
,m_aTableFilter(_rDB.m_aTableFilter)
|
|
|
|
,m_aTableTypeFilter(_rDB.m_aTableTypeFilter)
|
|
|
|
,m_xORB(_rxORB)
|
2002-08-12 08:21:59 +00:00
|
|
|
,m_xMasterConnection(_rxMaster)
|
2001-04-11 05:46:23 +00:00
|
|
|
,m_pTables(NULL)
|
|
|
|
,m_pViews(NULL)
|
2001-04-26 08:09:55 +00:00
|
|
|
,m_bSupportsViews(sal_False)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
DBG_CTOR(OConnection,NULL);
|
2001-10-08 06:28:39 +00:00
|
|
|
osl_incrementInterlockedCount(&m_refCount);
|
2002-08-12 08:21:59 +00:00
|
|
|
|
|
|
|
Reference< XProxyFactory > xProxyFactory(
|
|
|
|
_rxORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.ProxyFactory"))),UNO_QUERY);
|
|
|
|
Reference<XAggregation> xAgg = xProxyFactory->createProxy(_rxMaster.get());
|
|
|
|
setDelegation(xAgg,m_refCount);
|
|
|
|
DBG_ASSERT(m_xConnection.is(), "OConnection::OConnection : invalid master connection !");
|
|
|
|
if (!m_xProxyConnection->queryAggregation(getCppuType( (Reference<XWarningsSupplier>*)0)).hasValue())
|
|
|
|
{
|
|
|
|
DBG_ERROR("OConnection::OConnection : the connection is assumed to be a warnings supplier ! Won't use it !");
|
|
|
|
// as we're the owner of the conn and don't want to use it -> dispose
|
|
|
|
Reference< XComponent > xConnComp;
|
|
|
|
::comphelper::query_aggregation(m_xProxyConnection,xConnComp);
|
|
|
|
if (xConnComp.is())
|
|
|
|
xConnComp->dispose();
|
|
|
|
|
|
|
|
m_xMasterConnection = NULL;
|
|
|
|
}
|
2001-04-11 05:46:23 +00:00
|
|
|
try
|
|
|
|
{
|
2001-10-08 06:28:39 +00:00
|
|
|
sal_Bool bCase = sal_True;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
bCase = getMetaData()->storesMixedCaseQuotedIdentifiers();
|
|
|
|
}
|
|
|
|
catch(SQLException&)
|
|
|
|
{
|
|
|
|
}
|
2002-08-21 09:31:33 +00:00
|
|
|
m_pTables = new OTableContainer(_rTablesConfig,_rCommitLocation,*this, m_aMutex,this, bCase, this,this);
|
2001-04-26 08:09:55 +00:00
|
|
|
// check if we supports types
|
2002-08-12 08:21:59 +00:00
|
|
|
Reference<XResultSet> xRes = m_xConnection->getMetaData()->getTableTypes();
|
2001-04-26 08:09:55 +00:00
|
|
|
if(xRes.is())
|
|
|
|
{
|
|
|
|
::rtl::OUString sView = ::rtl::OUString::createFromAscii("VIEW");
|
|
|
|
Reference<XRow> xRow(xRes,UNO_QUERY);
|
|
|
|
while(xRes->next())
|
|
|
|
{
|
|
|
|
::rtl::OUString sValue = xRow->getString(1);
|
|
|
|
if( !xRow->wasNull() && sValue == sView)
|
|
|
|
{
|
|
|
|
m_bSupportsViews = sal_True;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-05-29 05:28:59 +00:00
|
|
|
// some dbs doesn't support this type so we should ask if a XViewsSupplier is supported
|
|
|
|
if(!m_bSupportsViews)
|
|
|
|
{
|
2002-10-25 08:02:00 +00:00
|
|
|
// Reference< XDriverAccess> xManager(m_xORB->createInstance(SERVICE_SDBC_DRIVERMANAGER), UNO_QUERY);
|
|
|
|
// Reference< XDataDefinitionSupplier > xSupp(xManager->getDriverByURL(m_xConnection->getMetaData()->getURL()),UNO_QUERY);
|
|
|
|
// // if we don't get the catalog from the original driver we have to try them all.
|
|
|
|
// if ( !xSupp.is() )
|
|
|
|
// {
|
|
|
|
// }
|
2001-05-29 05:28:59 +00:00
|
|
|
Reference< XViewsSupplier > xMaster;
|
2002-10-25 08:02:00 +00:00
|
|
|
m_xMasterTables = ::dbtools::getDataDefinitionByURLAndConnection(m_xConnection->getMetaData()->getURL(),m_xMasterConnection,m_xORB);
|
2001-10-05 05:47:13 +00:00
|
|
|
xMaster = Reference< XViewsSupplier >(m_xMasterTables,UNO_QUERY);
|
2001-05-29 05:28:59 +00:00
|
|
|
|
|
|
|
if (xMaster.is() && xMaster->getViews().is())
|
|
|
|
m_bSupportsViews = sal_True;
|
|
|
|
}
|
2001-04-26 08:09:55 +00:00
|
|
|
if(m_bSupportsViews)
|
2001-07-19 09:01:27 +00:00
|
|
|
{
|
2002-08-21 09:31:33 +00:00
|
|
|
m_pViews = new OViewContainer(*this, m_aMutex, this, bCase,this,this);
|
2001-07-19 09:01:27 +00:00
|
|
|
m_pViews->addContainerListener(m_pTables);
|
|
|
|
m_pTables->addContainerListener(m_pViews);
|
|
|
|
}
|
2001-04-11 05:46:23 +00:00
|
|
|
}
|
|
|
|
catch(const SQLException&)
|
|
|
|
{
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
// initialize the queries
|
2000-10-18 15:16:39 +00:00
|
|
|
DBG_ASSERT(_rDB.m_aConfigurationNode.isValid(), "OConnection::OConnection : invalid configuration location of my parent !");
|
2001-10-08 06:28:39 +00:00
|
|
|
osl_decrementInterlockedCount( &m_refCount );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
OConnection::~OConnection()
|
|
|
|
{
|
2000-11-14 12:32:59 +00:00
|
|
|
delete m_pTables;
|
2001-03-29 06:07:13 +00:00
|
|
|
delete m_pViews;
|
2000-09-18 23:16:46 +00:00
|
|
|
DBG_DTOR(OConnection,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-02 16:01:04 +00:00
|
|
|
// IWarningsContainer
|
2001-08-24 12:15:06 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OConnection::appendWarning(const SQLException& _rWarning)
|
|
|
|
{
|
|
|
|
implConcatWarnings(m_aAdditionalWarnings, makeAny(_rWarning));
|
|
|
|
}
|
|
|
|
|
2001-03-02 16:01:04 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OConnection::appendWarning(const SQLContext& _rContext)
|
|
|
|
{
|
|
|
|
implConcatWarnings(m_aAdditionalWarnings, makeAny(_rContext));
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OConnection::appendWarning(const SQLWarning& _rWarning)
|
|
|
|
{
|
|
|
|
implConcatWarnings(m_aAdditionalWarnings, makeAny(_rWarning));
|
|
|
|
}
|
|
|
|
|
|
|
|
// XWarningsSupplier
|
|
|
|
//--------------------------------------------------------------------------
|
2002-08-12 08:21:59 +00:00
|
|
|
Any SAL_CALL OConnection::getWarnings() throw(SQLException, RuntimeException)
|
2001-03-02 16:01:04 +00:00
|
|
|
{
|
2002-08-12 08:21:59 +00:00
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
|
|
|
Reference<XWarningsSupplier> xWarnings;
|
|
|
|
::comphelper::query_aggregation(m_xProxyConnection,xWarnings);
|
|
|
|
Any aReturn = xWarnings->getWarnings();
|
2001-03-02 16:01:04 +00:00
|
|
|
if (!m_aAdditionalWarnings.hasValue())
|
|
|
|
return aReturn;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// copy m_aAdditionalWarnings, and append the original warnings
|
|
|
|
Any aOverallWarnings(m_aAdditionalWarnings);
|
|
|
|
implConcatWarnings(aOverallWarnings, aReturn);
|
|
|
|
return aOverallWarnings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
void OConnection::implConcatWarnings(Any& _rChainLeft, const Any& _rChainRight)
|
|
|
|
{
|
|
|
|
if (!_rChainLeft.hasValue())
|
|
|
|
_rChainLeft = _rChainRight;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// to travel the chain by reference (and not by value), we need the getValue ...
|
|
|
|
// looks like a hack, but the meaning of getValue is documented, and it's the only chance for reference-traveling ....
|
|
|
|
|
|
|
|
DBG_ASSERT(SQLExceptionInfo(_rChainLeft).isValid(), "OConnection::appendWarning: invalid warnings chain (this will crash)!");
|
|
|
|
|
|
|
|
const SQLException* pChainTravel = static_cast<const SQLException*>(_rChainLeft.getValue());
|
|
|
|
SQLExceptionIteratorHelper aReferenceIterHelper(pChainTravel);
|
|
|
|
while (aReferenceIterHelper.hasMoreElements())
|
|
|
|
pChainTravel = aReferenceIterHelper.next();
|
|
|
|
|
|
|
|
// reached the end of the chain, and pChainTravel points to the last element
|
|
|
|
const_cast<SQLException*>(pChainTravel)->NextException = _rChainRight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
|
|
|
|
{
|
2002-08-12 08:21:59 +00:00
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
|
|
|
Reference<XWarningsSupplier> xWarnings;
|
|
|
|
::comphelper::query_aggregation(m_xProxyConnection,xWarnings);
|
|
|
|
xWarnings->clearWarnings();
|
2001-03-02 16:01:04 +00:00
|
|
|
m_aAdditionalWarnings.clear();
|
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// com::sun::star::lang::XTypeProvider
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Sequence< Type > OConnection::getTypes() throw (RuntimeException)
|
|
|
|
{
|
2002-08-12 08:21:59 +00:00
|
|
|
if ( m_bSupportsViews )
|
|
|
|
return concatSequences(OSubComponent::getTypes(), OConnection_Base::getTypes());
|
|
|
|
|
|
|
|
// here views are supported
|
|
|
|
Sequence<Type> aTypes = OSubComponent::getTypes();
|
2001-04-26 08:09:55 +00:00
|
|
|
Sequence<Type> aConTypes = OConnection_Base::getTypes();
|
|
|
|
sal_Int32 nSize = aTypes.getLength();
|
|
|
|
aTypes.realloc(aTypes.getLength() + aConTypes.getLength() - 1);
|
|
|
|
Type* pBegin = aConTypes.getArray();
|
|
|
|
Type* pEnd = pBegin + aConTypes.getLength();
|
|
|
|
Type aTypeToHide = getCppuType( (Reference<XViewsSupplier>*)0);
|
|
|
|
for (; pBegin != pEnd; ++pBegin)
|
|
|
|
{
|
|
|
|
if(*pBegin != aTypeToHide)
|
|
|
|
aTypes.getArray()[nSize++] = *pBegin;
|
|
|
|
}
|
|
|
|
return aTypes;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Sequence< sal_Int8 > OConnection::getImplementationId() throw (RuntimeException)
|
|
|
|
{
|
2001-07-18 07:45:32 +00:00
|
|
|
return getUnoTunnelImplementationId();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// com::sun::star::uno::XInterface
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Any OConnection::queryInterface( const Type & rType ) throw (RuntimeException)
|
|
|
|
{
|
2001-04-26 08:09:55 +00:00
|
|
|
if(!m_bSupportsViews && rType == getCppuType( (Reference<XViewsSupplier>*)0))
|
|
|
|
return Any();
|
2000-09-18 23:16:46 +00:00
|
|
|
Any aReturn = OSubComponent::queryInterface( rType );
|
|
|
|
if (!aReturn.hasValue())
|
2002-08-12 08:21:59 +00:00
|
|
|
{
|
2000-09-18 23:16:46 +00:00
|
|
|
aReturn = OConnection_Base::queryInterface( rType );
|
2002-08-12 08:21:59 +00:00
|
|
|
if (!aReturn.hasValue())
|
|
|
|
aReturn = OConnectionWrapper::queryInterface( rType );
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
return aReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
2001-11-01 15:29:21 +00:00
|
|
|
void OConnection::acquire() throw ()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
OSubComponent::acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
2001-11-01 15:29:21 +00:00
|
|
|
void OConnection::release() throw ()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
OSubComponent::release();
|
|
|
|
}
|
|
|
|
|
|
|
|
// OSubComponent
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OConnection::disposing()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
OSubComponent::disposing();
|
2002-08-12 08:21:59 +00:00
|
|
|
for (OWeakRefArrayIterator i = m_aStatements.begin(); m_aStatements.end() != i; i++)
|
|
|
|
{
|
|
|
|
Reference< XComponent > xComp(i->get(), UNO_QUERY);
|
|
|
|
if (xComp.is())
|
|
|
|
xComp->dispose();
|
|
|
|
}
|
|
|
|
m_aStatements.clear();
|
|
|
|
m_xMasterTables = NULL;
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-02-14 14:04:16 +00:00
|
|
|
if(m_pTables)
|
2002-08-23 04:56:21 +00:00
|
|
|
m_pTables->dispose();
|
2001-03-29 06:07:13 +00:00
|
|
|
if(m_pViews)
|
2002-08-23 04:56:21 +00:00
|
|
|
m_pViews->dispose();
|
2000-09-18 23:16:46 +00:00
|
|
|
m_aQueries.dispose();
|
|
|
|
|
|
|
|
for (OWeakRefArrayIterator j = m_aComposers.begin(); m_aComposers.end() != j; j++)
|
|
|
|
{
|
|
|
|
Reference< XComponent > xComp(j->get(), UNO_QUERY);
|
|
|
|
if (xComp.is())
|
|
|
|
xComp->dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_aComposers.clear();
|
|
|
|
|
2002-08-12 08:21:59 +00:00
|
|
|
if (m_xMasterConnection.is())
|
|
|
|
m_xMasterConnection->close();
|
2000-09-18 23:16:46 +00:00
|
|
|
m_xMasterConnection = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XChild
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Reference< XInterface > OConnection::getParent(void) throw( RuntimeException )
|
|
|
|
{
|
2002-12-12 09:43:23 +00:00
|
|
|
MutexGuard aGuard(m_aMutex);
|
2000-09-18 23:16:46 +00:00
|
|
|
checkDisposed();
|
|
|
|
return m_xParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OConnection::setParent(const Reference< XInterface > & Parent) throw( NoSupportException, RuntimeException )
|
|
|
|
{
|
|
|
|
throw NoSupportException();
|
|
|
|
}
|
|
|
|
|
|
|
|
// XSQLQueryComposerFactory
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Reference< XSQLQueryComposer > OConnection::createQueryComposer(void) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
|
|
|
|
|
|
|
// get the supplier of the database
|
|
|
|
ODatabaseSource* pParent = NULL;
|
2000-11-03 13:42:50 +00:00
|
|
|
if (!comphelper::getImplementation(pParent, m_xParent))
|
2000-09-18 23:16:46 +00:00
|
|
|
throw RuntimeException();
|
|
|
|
|
|
|
|
// Reference< XNumberFormatsSupplier > xSupplier = pParent->getNumberFormatsSupplier();
|
|
|
|
Reference< XSQLQueryComposer > xComposer(new OQueryComposer(getTables(),this, m_xORB));
|
|
|
|
m_aComposers.push_back(WeakReferenceHelper(xComposer));
|
|
|
|
return xComposer;
|
|
|
|
}
|
2002-08-21 09:31:33 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OConnection::refresh(const Reference< XNameAccess >& _rToBeRefreshed)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-08-21 09:31:33 +00:00
|
|
|
if ( _rToBeRefreshed == Reference< XNameAccess >(m_pTables) )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-08-21 09:31:33 +00:00
|
|
|
if (!m_pTables->isInitialized())
|
2001-10-05 05:47:13 +00:00
|
|
|
{
|
2002-08-21 09:31:33 +00:00
|
|
|
|
|
|
|
// check if out "master connection" can supply tables
|
|
|
|
if(!m_xMasterTables.is())
|
2001-10-08 06:28:39 +00:00
|
|
|
{
|
2002-08-21 09:31:33 +00:00
|
|
|
try
|
|
|
|
{
|
2002-10-25 08:02:00 +00:00
|
|
|
m_xMasterTables = ::dbtools::getDataDefinitionByURLAndConnection(m_xConnection->getMetaData()->getURL(),m_xMasterConnection,m_xORB);
|
2002-08-21 09:31:33 +00:00
|
|
|
}
|
|
|
|
catch(SQLException&)
|
|
|
|
{
|
|
|
|
}
|
2001-10-08 06:28:39 +00:00
|
|
|
}
|
2002-08-21 09:31:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (m_xMasterTables.is() && m_xMasterTables->getTables().is())
|
|
|
|
{ // yes -> wrap them
|
|
|
|
m_pTables->construct(m_xMasterTables->getTables(),m_aTableFilter, m_aTableTypeFilter);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // no -> use an own container
|
|
|
|
m_pTables->construct(m_aTableFilter, m_aTableTypeFilter);
|
2001-10-08 06:28:39 +00:00
|
|
|
}
|
2001-10-05 05:47:13 +00:00
|
|
|
}
|
2002-08-21 09:31:33 +00:00
|
|
|
}
|
|
|
|
else if ( _rToBeRefreshed == Reference< XNameAccess >(m_pViews) )
|
|
|
|
{
|
|
|
|
if (!m_pViews->isInitialized())
|
|
|
|
{
|
|
|
|
// check if out "master connection" can supply tables
|
|
|
|
Reference< XViewsSupplier > xMaster(m_xMasterTables,UNO_QUERY);
|
|
|
|
if(!m_xMasterTables.is())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2002-10-25 08:02:00 +00:00
|
|
|
m_xMasterTables = ::dbtools::getDataDefinitionByURLAndConnection(m_xConnection->getMetaData()->getURL(),m_xMasterConnection,m_xORB);
|
2002-08-21 09:31:33 +00:00
|
|
|
xMaster = Reference< XViewsSupplier >(m_xMasterTables,UNO_QUERY);
|
|
|
|
}
|
|
|
|
catch(SQLException&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2001-08-24 05:40:35 +00:00
|
|
|
|
2002-08-21 09:31:33 +00:00
|
|
|
if (xMaster.is() && xMaster->getViews().is())
|
|
|
|
m_pViews->construct(xMaster->getViews(),m_aTableFilter, m_aTableTypeFilter);
|
|
|
|
else
|
|
|
|
m_pViews->construct(m_aTableFilter, m_aTableTypeFilter);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-21 09:31:33 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// XTablesSupplier
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Reference< XNameAccess > OConnection::getTables() throw( RuntimeException )
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
|
|
|
|
|
|
|
refresh(m_pTables);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2000-11-14 12:32:59 +00:00
|
|
|
return m_pTables;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2001-03-29 06:07:13 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XNameAccess > SAL_CALL OConnection::getViews( ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
|
|
|
|
2002-08-23 04:56:21 +00:00
|
|
|
refresh(m_pViews);
|
2001-03-29 06:07:13 +00:00
|
|
|
|
|
|
|
return m_pViews;
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
// XQueriesSupplier
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
Reference< XNameAccess > OConnection::getQueries(void) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
|
|
|
|
|
|
|
return static_cast<XNameAccess*>(&m_aQueries);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ::com::sun::star::sdb::XCommandPreparation
|
|
|
|
//------------------------------------------------------------------------------
|
2001-03-29 06:07:13 +00:00
|
|
|
Reference< XPreparedStatement > SAL_CALL OConnection::prepareCommand( const ::rtl::OUString& command, sal_Int32 commandType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed();
|
|
|
|
|
|
|
|
rtl::OUString aStatement;
|
|
|
|
switch (commandType)
|
|
|
|
{
|
|
|
|
case CommandType::TABLE:
|
|
|
|
aStatement = rtl::OUString::createFromAscii("SELECT * FROM ");
|
2002-10-07 12:09:48 +00:00
|
|
|
aStatement += ::dbtools::quoteTableName(getMetaData(), command,::dbtools::eInDataManipulation);
|
2000-09-18 23:16:46 +00:00
|
|
|
break;
|
|
|
|
case CommandType::QUERY:
|
|
|
|
if (m_aQueries.hasByName(command))
|
|
|
|
{
|
|
|
|
Reference< XPropertySet > xQuery;
|
2001-02-14 14:04:16 +00:00
|
|
|
::cppu::extractInterface(xQuery,m_aQueries.getByName(command));
|
2000-09-18 23:16:46 +00:00
|
|
|
xQuery->getPropertyValue(PROPERTY_COMMAND) >>= aStatement;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aStatement = command;
|
|
|
|
}
|
|
|
|
// TODO EscapeProcessing
|
|
|
|
return prepareStatement(aStatement);
|
|
|
|
}
|
2001-07-18 07:45:32 +00:00
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId()
|
|
|
|
{
|
|
|
|
static ::cppu::OImplementationId * pId = 0;
|
|
|
|
if (! pId)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
|
|
|
if (! pId)
|
|
|
|
{
|
|
|
|
static ::cppu::OImplementationId aId;
|
|
|
|
pId = &aId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pId->getImplementationId();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// com::sun::star::XUnoTunnel
|
|
|
|
sal_Int64 SAL_CALL OConnection::getSomething( const Sequence< sal_Int8 >& rId ) throw(RuntimeException)
|
|
|
|
{
|
|
|
|
if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
|
|
|
|
return (sal_Int64)this;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2001-07-18 07:45:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OConnection::flushMembers()
|
|
|
|
{
|
|
|
|
if(m_pTables)
|
|
|
|
m_pTables->flush();
|
|
|
|
m_aQueries.flush();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OConnection::setNewConfigNode(const ::utl::OConfigurationTreeRoot& _aConfigTreeNode)
|
|
|
|
{
|
|
|
|
if(m_pTables)
|
|
|
|
m_pTables->setNewConfigNode(_aConfigTreeNode);
|
|
|
|
|
|
|
|
m_aQueries.setNewConfigNode(_aConfigTreeNode.openNode(CONFIGKEY_DBLINK_QUERYDOCUMENTS).cloneAsRoot());
|
|
|
|
}
|
2000-10-18 15:16:39 +00:00
|
|
|
//........................................................................
|
|
|
|
} // namespace dbaccess
|
|
|
|
//........................................................................
|
2000-09-18 23:16:46 +00:00
|
|
|
|