xref: /AOO41X/main/connectivity/source/inc/ado/AConnection.hxx (revision caf5cd79edad04a48dcaf209068b3b89eae4622e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CONNECTIVITY_ADO_ACONNECTION_HXX_
24 #define _CONNECTIVITY_ADO_ACONNECTION_HXX_
25 
26 #include <com/sun/star/sdbc/SQLWarning.hpp>
27 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include "OSubComponent.hxx"
30 #include <map>
31 #include "connectivity/CommonTools.hxx"
32 #include "OTypeInfo.hxx"
33 #include "TConnection.hxx"
34 #include "ado/Awrapado.hxx"
35 
36 namespace connectivity
37 {
38     namespace ado
39     {
40         struct OExtendedTypeInfo
41         {
42             ::connectivity::OTypeInfo       aSimpleType;    // the general type info
43             DataTypeEnum                    eType;
44 
getDBNameconnectivity::ado::OExtendedTypeInfo45             inline ::rtl::OUString getDBName() const { return aSimpleType.aTypeName; }
46         };
47 
48         class WpADOConnection;
49         class ODriver;
50         class OCatalog;
51         typedef ::std::multimap<DataTypeEnum, OExtendedTypeInfo*>       OTypeInfoMap;
52         typedef connectivity::OMetaConnection                           OConnection_BASE;
53 
54 
55         class OConnection : public OConnection_BASE,
56                             public connectivity::OSubComponent<OConnection, OConnection_BASE>
57         {
58             friend class connectivity::OSubComponent<OConnection, OConnection_BASE>;
59 
60         protected:
61             //====================================================================
62             // Data attributes
63             //====================================================================
64             OTypeInfoMap                m_aTypeInfo;    //  vector containing an entry
65                                                                                 //  for each row returned by
66                                                                                 //  DatabaseMetaData.getTypeInfo.
67             ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>      m_xCatalog;
68             ODriver*                    m_pDriver;
69         private:
70             WpADOConnection*            m_pAdoConnection;
71             OCatalog*                   m_pCatalog;
72             sal_Int32                   m_nEngineType;
73             sal_Bool                    m_bClosed;
74             sal_Bool                    m_bAutocommit;
75 
76         protected:
77             void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException);
78         public:
79 
80             OConnection(ODriver*        _pDriver) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
81             //  OConnection(const SQLHANDLE _pConnectionHandle);
82             ~OConnection();
83             void construct(const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info);
84 
85             void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
86 
87             //XUnoTunnel
88             virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException);
89             static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
90             // XServiceInfo
91             DECLARE_SERVICE_INFO();
92             // OComponentHelper
93             virtual void SAL_CALL disposing(void);
94             // XInterface
95             virtual void SAL_CALL release() throw();
96 
97             // XConnection
98             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);
99             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);
100             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);
101             virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
102             virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
103             virtual sal_Bool SAL_CALL getAutoCommit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
104             virtual void SAL_CALL commit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
105             virtual void SAL_CALL rollback(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
106             virtual sal_Bool SAL_CALL isClosed(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
107             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);
108             virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
109             virtual sal_Bool SAL_CALL isReadOnly(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
110             virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
111             virtual ::rtl::OUString SAL_CALL getCatalog(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
112             virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
113             virtual sal_Int32 SAL_CALL getTransactionIsolation(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
114             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);
115             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);
116             // XCloseable
117             virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
118             // XWarningsSupplier
119             virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
120             virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
121             //
getConnection()122             WpADOConnection* getConnection() { return m_pAdoConnection; }
setCatalog(const::com::sun::star::uno::WeakReference<::com::sun::star::sdbcx::XTablesSupplier> & _xCat)123             void setCatalog(const ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>& _xCat) { m_xCatalog = _xCat; }
setCatalog(OCatalog * _pCatalog)124             void setCatalog(OCatalog* _pCatalog) { m_pCatalog = _pCatalog; }
125 
getTypeInfo() const126             const OTypeInfoMap* getTypeInfo() const { return &m_aTypeInfo;}
getAdoCatalog() const127             OCatalog* getAdoCatalog() const
128             {
129                 if ( m_xCatalog.get().is() )
130                     return m_pCatalog;
131                 return NULL;
132             }
133 
getEngineType() const134             sal_Int32 getEngineType()   const { return m_nEngineType; }
getDriver() const135             ODriver*  getDriver()       const { return m_pDriver; }
136 
137             static const OExtendedTypeInfo* getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
138                                DataTypeEnum _nType,
139                                const ::rtl::OUString& _sTypeName,
140                                sal_Int32 _nPrecision,
141                                sal_Int32 _nScale,
142                                sal_Bool& _brForceToType);
143         };
144     }
145 }
146 #endif // _CONNECTIVITY_ADO_ACONNECTION_HXX_
147 
148