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