1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir #ifndef DBA_CORE_SHARED_CONNECTION_HXX 24cdf0e10cSrcweir #define DBA_CORE_SHARED_CONNECTION_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #ifndef _CONNECTIVITY_CONNECTIONWRAPPER_HXX_ 27cdf0e10cSrcweir #include "connectivity/ConnectionWrapper.hxx" 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir #ifndef _CPPUHELPER_COMPONENT_HXX_ 30cdf0e10cSrcweir #include <cppuhelper/component.hxx> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #ifndef _CONNECTIVITY_COMMONTOOLS_HXX_ 33cdf0e10cSrcweir #include <connectivity/CommonTools.hxx> 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #ifndef _CPPUHELPER_COMPBASE1_HXX_ 36cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_ 39cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XWARNINGSSUPPLIER_HPP_ 42cdf0e10cSrcweir #include <com/sun/star/sdbc/XWarningsSupplier.hpp> 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_SQLWARNING_HPP_ 45cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp> 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ 48cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XSQLQUERYCOMPOSERFACTORY_HPP_ 51cdf0e10cSrcweir #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> 52cdf0e10cSrcweir #endif 53cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XCOMMANDPREPARATION_HPP_ 54cdf0e10cSrcweir #include <com/sun/star/sdb/XCommandPreparation.hpp> 55cdf0e10cSrcweir #endif 56cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ 57cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 58cdf0e10cSrcweir #endif 59cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ 60cdf0e10cSrcweir #include <com/sun/star/sdbcx/XViewsSupplier.hpp> 61cdf0e10cSrcweir #endif 62cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_ 63cdf0e10cSrcweir #include <com/sun/star/sdb/XQueriesSupplier.hpp> 64cdf0e10cSrcweir #endif 65cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_ 66cdf0e10cSrcweir #include <comphelper/sequence.hxx> 67cdf0e10cSrcweir #endif 68cdf0e10cSrcweir 69cdf0e10cSrcweir 70cdf0e10cSrcweir namespace dbaccess 71cdf0e10cSrcweir { 72cdf0e10cSrcweir //======================================================================================= 73cdf0e10cSrcweir //= OSharedConnection: This class implements a simple forwarding of connection calls. 74cdf0e10cSrcweir //= All methods will be forwarded with exception of the set methods, which are not allowed 75cdf0e10cSrcweir //= to be called on shared connections. Instances of this class will be created when the 76cdf0e10cSrcweir //= datasource is asked for not isolated connection. 77cdf0e10cSrcweir //======================================================================================= 78cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::sdbc::XConnection 79cdf0e10cSrcweir > OSharedConnection_BASE; 80cdf0e10cSrcweir typedef ::connectivity::OConnectionWrapper OSharedConnection_BASE2; 81cdf0e10cSrcweir 82cdf0e10cSrcweir class OSharedConnection : public ::comphelper::OBaseMutex 83cdf0e10cSrcweir , public OSharedConnection_BASE 84cdf0e10cSrcweir , public OSharedConnection_BASE2 85cdf0e10cSrcweir { 86cdf0e10cSrcweir protected: 87cdf0e10cSrcweir virtual void SAL_CALL disposing(void); 88cdf0e10cSrcweir virtual ~OSharedConnection(); 89cdf0e10cSrcweir public: 90cdf0e10cSrcweir OSharedConnection(::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >& _rxProxyConnection); 91cdf0e10cSrcweir 92cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException); 93cdf0e10cSrcweir acquire()94cdf0e10cSrcweir virtual void SAL_CALL acquire() throw() { OSharedConnection_BASE::acquire(); } release()95cdf0e10cSrcweir virtual void SAL_CALL release() throw() { OSharedConnection_BASE::release(); } getTypes()96cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir return ::comphelper::concatSequences( 99cdf0e10cSrcweir OSharedConnection_BASE::getTypes(), 100cdf0e10cSrcweir OSharedConnection_BASE2::getTypes() 101cdf0e10cSrcweir ); 102cdf0e10cSrcweir } 103cdf0e10cSrcweir queryInterface(const::com::sun::star::uno::Type & _rType)104cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn = OSharedConnection_BASE::queryInterface(_rType); 107cdf0e10cSrcweir if ( !aReturn.hasValue() ) 108cdf0e10cSrcweir aReturn = OSharedConnection_BASE2::queryInterface(_rType); 109cdf0e10cSrcweir return aReturn; 110cdf0e10cSrcweir } 111cdf0e10cSrcweir // -------------------------------------------------------------------------------- 112cdf0e10cSrcweir // XCloseable close()113cdf0e10cSrcweir virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir { 116cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 117cdf0e10cSrcweir ::connectivity::checkDisposed(rBHelper.bDisposed); 118cdf0e10cSrcweir 119cdf0e10cSrcweir } 120cdf0e10cSrcweir dispose(); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir // XConnection setAutoCommit(sal_Bool)124cdf0e10cSrcweir virtual void SAL_CALL setAutoCommit( sal_Bool /*autoCommit*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any()); 127cdf0e10cSrcweir } setReadOnly(sal_Bool)128cdf0e10cSrcweir virtual void SAL_CALL setReadOnly( sal_Bool /*readOnly*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any()); 131cdf0e10cSrcweir } setCatalog(const::rtl::OUString &)132cdf0e10cSrcweir virtual void SAL_CALL setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any()); 135cdf0e10cSrcweir } setTransactionIsolation(sal_Int32)136cdf0e10cSrcweir virtual void SAL_CALL setTransactionIsolation( sal_Int32 /*level*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any()); 139cdf0e10cSrcweir } setTypeMap(const::com::sun::star::uno::Reference<::com::sun::star::container::XNameAccess> &)140cdf0e10cSrcweir virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir throw ::com::sun::star::sdbc::SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("This call is not allowed when sharing connections.")),*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S10000")),0,::com::sun::star::uno::Any()); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir // XConnection 145cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 146cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 147cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 148cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 149cdf0e10cSrcweir virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 150cdf0e10cSrcweir virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 151cdf0e10cSrcweir virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 152cdf0e10cSrcweir virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 153cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 154cdf0e10cSrcweir virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 155cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 156cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 157cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); 158cdf0e10cSrcweir }; 159cdf0e10cSrcweir 160cdf0e10cSrcweir #ifdef IMPLEMENT_GET_IMPLEMENTATION_ID 161cdf0e10cSrcweir IMPLEMENT_GET_IMPLEMENTATION_ID( OSharedConnection ); 162cdf0e10cSrcweir #endif 163cdf0e10cSrcweir //........................................................................ 164cdf0e10cSrcweir } // namespace dbaccess 165cdf0e10cSrcweir //........................................................................ 166cdf0e10cSrcweir #endif // DBA_CORE_SHARED_CONNECTION_HXX 167cdf0e10cSrcweir 168cdf0e10cSrcweir 169