Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : : #ifndef _CONNECTIVITY_ODBC_OCONNECTION_HXX_
20 : : #define _CONNECTIVITY_ODBC_OCONNECTION_HXX_
21 : :
22 : : #include <com/sun/star/sdbc/SQLWarning.hpp>
23 : : #include <com/sun/star/beans/PropertyValue.hpp>
24 : : #include "odbc/OFunctiondefs.hxx"
25 : : #include "odbc/odbcbasedllapi.hxx"
26 : : #include "connectivity/OSubComponent.hxx"
27 : : #include "connectivity/CommonTools.hxx"
28 : : #include "TConnection.hxx"
29 : : #include "OTypeInfo.hxx"
30 : : #include <cppuhelper/weakref.hxx>
31 : : #include "AutoRetrievingBase.hxx"
32 : : #include <osl/module.h>
33 : :
34 : :
35 : : #include <map>
36 : :
37 : : namespace connectivity
38 : : {
39 : : namespace odbc
40 : : {
41 : : class ODBCDriver;
42 : :
43 : : typedef connectivity::OMetaConnection OConnection_BASE;
44 : : typedef ::std::vector< ::connectivity::OTypeInfo> TTypeInfoVector;
45 : :
46 : : class OOO_DLLPUBLIC_ODBCBASE OConnection :
47 : : public OConnection_BASE,
48 : : public connectivity::OSubComponent<OConnection, OConnection_BASE>,
49 : : public OAutoRetrievingBase
50 : : {
51 : : friend class connectivity::OSubComponent<OConnection, OConnection_BASE>;
52 : :
53 : : protected:
54 : : //====================================================================
55 : : // Data attributes
56 : : //====================================================================
57 : : ::std::map< SQLHANDLE,OConnection*> m_aConnections; // holds all connectionas which are need for serveral statements
58 : : TTypeInfoVector m_aTypeInfo; // vector containing an entry
59 : : // for each row returned by
60 : : // DatabaseMetaData.getTypeInfo.
61 : :
62 : :
63 : : ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by
64 : : // an operation
65 : : ::rtl::OUString m_sUser; // the user name
66 : : ODBCDriver* m_pDriver; // Pointer to the owning
67 : : // driver object
68 : :
69 : : SQLHANDLE m_aConnectionHandle;
70 : : SQLHANDLE m_pDriverHandleCopy; // performance reason
71 : : sal_Int32 m_nStatementCount;
72 : : sal_Bool m_bClosed;
73 : : sal_Bool m_bUseCatalog; // should we use the catalog on filebased databases
74 : : sal_Bool m_bUseOldDateFormat;
75 : : sal_Bool m_bParameterSubstitution;
76 : : sal_Bool m_bIgnoreDriverPrivileges;
77 : : sal_Bool m_bPreventGetVersionColumns; // #i60273#
78 : : sal_Bool m_bReadOnly;
79 : :
80 : :
81 : : SQLRETURN OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, sal_Bool bSilent);
82 : :
83 : : virtual OConnection* cloneConnection(); // creates a new connection
84 : :
85 : : public:
86 : : oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const;
87 : : virtual SQLRETURN Construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
88 : :
89 : : OConnection(const SQLHANDLE _pDriverHandle,ODBCDriver* _pDriver);
90 : : // OConnection(const SQLHANDLE _pConnectionHandle);
91 : : virtual ~OConnection();
92 : :
93 : : void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
94 : :
95 : : // OComponentHelper
96 : : virtual void SAL_CALL disposing(void);
97 : : // XInterface
98 : : virtual void SAL_CALL release() throw();
99 : :
100 : : // XServiceInfo
101 : : DECLARE_SERVICE_INFO();
102 : : // XConnection
103 : : 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);
104 : : 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);
105 : : 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);
106 : : virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
107 : : virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
108 : : virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
109 : : virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
110 : : virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
111 : : virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
112 : : 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);
113 : : virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
114 : : virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
115 : : virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116 : : virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
117 : : virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
118 : : virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
119 : : 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);
120 : : 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);
121 : : // XCloseable
122 : : virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
123 : : // XWarningsSupplier
124 : : virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
125 : : virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
126 : : //
127 : 0 : SQLHANDLE getConnection() { return m_aConnectionHandle; }
128 : :
129 : : // should we use the catalog on filebased databases
130 : 0 : inline sal_Bool isCatalogUsed() const { return m_bUseCatalog; }
131 : 0 : inline sal_Bool isParameterSubstitutionEnabled() const { return m_bParameterSubstitution; }
132 : 0 : inline sal_Bool isIgnoreDriverPrivilegesEnabled() const { return m_bIgnoreDriverPrivileges; }
133 : 0 : inline sal_Bool preventGetVersionColumns() const { return m_bPreventGetVersionColumns; }
134 : 0 : inline sal_Bool useOldDateFormat() const { return m_bUseOldDateFormat; }
135 : : inline SQLHANDLE getDriverHandle() const { return m_pDriverHandleCopy;}
136 : 0 : inline ODBCDriver* getDriver() const { return m_pDriver;}
137 : : inline ::rtl::OUString getUserName() const { return m_sUser; }
138 : :
139 : : SQLHANDLE createStatementHandle();
140 : : // close and free the handle and set it to SQL_NULLHANDLE
141 : : void freeStatementHandle(SQLHANDLE& _pHandle);
142 : :
143 : : const TTypeInfoVector& getTypeInfo() const { return m_aTypeInfo; }
144 : : };
145 : : }
146 : : }
147 : : #endif // _CONNECTIVITY_ODBC_OCONNECTION_HXX_
148 : :
149 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|