1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OCONNECTION_HXX
20 #define INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OCONNECTION_HXX
22 #include <com/sun/star/sdbc/SQLWarning.hpp>
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include <connectivity/odbc.hxx>
25 #include <odbc/odbcbasedllapi.hxx>
26 #include <connectivity/CommonTools.hxx>
27 #include <TConnection.hxx>
28 #include <OTypeInfo.hxx>
29 #include <odbc/OTools.hxx>
30 #include <cppuhelper/weakref.hxx>
31 #include <AutoRetrievingBase.hxx>
32 #include <osl/module.h>
37 namespace connectivity
43 typedef connectivity::OMetaConnection OConnection_BASE
;
44 typedef std::vector
< ::connectivity::OTypeInfo
> TTypeInfoVector
;
46 class OOO_DLLPUBLIC_ODBCBASE OConnection final
:
47 public OConnection_BASE
,
48 public OAutoRetrievingBase
52 std::map
< SQLHANDLE
, rtl::Reference
<OConnection
>> m_aConnections
; // holds all connections which are need for several statements
55 OUString m_sUser
; // the user name
56 rtl::Reference
<ODBCDriver
>
57 m_xDriver
; // Pointer to the owning
60 SQLHANDLE m_aConnectionHandle
;
61 SQLHANDLE m_pDriverHandleCopy
; // performance reason
62 sal_Int32 m_nStatementCount
;
64 bool m_bUseCatalog
; // should we use the catalog on filebased databases
65 bool m_bUseOldDateFormat
;
66 bool m_bIgnoreDriverPrivileges
;
67 bool m_bPreventGetVersionColumns
; // #i60273#
71 SQLRETURN
OpenConnection(const OUString
& aConnectStr
,sal_Int32 nTimeOut
, bool bSilent
);
74 oslGenericFunction
getOdbcFunction(ODBC3SQLFunctionId _nIndex
) const;
75 /// @throws css::sdbc::SQLException
76 SQLRETURN
Construct( const OUString
& url
,const css::uno::Sequence
< css::beans::PropertyValue
>& info
);
78 OConnection(const SQLHANDLE _pDriverHandle
,ODBCDriver
* _pDriver
);
79 // OConnection(const SQLHANDLE _pConnectionHandle);
80 virtual ~OConnection() override
;
83 virtual void SAL_CALL
disposing() override
;
86 DECLARE_SERVICE_INFO();
88 virtual css::uno::Reference
< css::sdbc::XStatement
> SAL_CALL
createStatement( ) override
;
89 virtual css::uno::Reference
< css::sdbc::XPreparedStatement
> SAL_CALL
prepareStatement( const OUString
& sql
) override
;
90 virtual css::uno::Reference
< css::sdbc::XPreparedStatement
> SAL_CALL
prepareCall( const OUString
& sql
) override
;
91 virtual OUString SAL_CALL
nativeSQL( const OUString
& sql
) override
;
92 virtual void SAL_CALL
setAutoCommit( sal_Bool autoCommit
) override
;
93 virtual sal_Bool SAL_CALL
getAutoCommit( ) override
;
94 virtual void SAL_CALL
commit( ) override
;
95 virtual void SAL_CALL
rollback( ) override
;
96 virtual sal_Bool SAL_CALL
isClosed( ) override
;
97 virtual css::uno::Reference
< css::sdbc::XDatabaseMetaData
> SAL_CALL
getMetaData( ) override
;
98 virtual void SAL_CALL
setReadOnly( sal_Bool readOnly
) override
;
99 virtual sal_Bool SAL_CALL
isReadOnly( ) override
;
100 virtual void SAL_CALL
setCatalog( const OUString
& catalog
) override
;
101 virtual OUString SAL_CALL
getCatalog( ) override
;
102 virtual void SAL_CALL
setTransactionIsolation( sal_Int32 level
) override
;
103 virtual sal_Int32 SAL_CALL
getTransactionIsolation( ) override
;
104 virtual css::uno::Reference
< css::container::XNameAccess
> SAL_CALL
getTypeMap( ) override
;
105 virtual void SAL_CALL
setTypeMap( const css::uno::Reference
< css::container::XNameAccess
>& typeMap
) override
;
107 virtual void SAL_CALL
close( ) override
;
109 virtual css::uno::Any SAL_CALL
getWarnings( ) override
;
110 virtual void SAL_CALL
clearWarnings( ) override
;
112 SQLHANDLE
getConnection() { return m_aConnectionHandle
; }
114 // should we use the catalog on filebased databases
115 bool isCatalogUsed() const { return m_bUseCatalog
; }
116 bool isIgnoreDriverPrivilegesEnabled() const { return m_bIgnoreDriverPrivileges
; }
117 bool preventGetVersionColumns() const { return m_bPreventGetVersionColumns
; }
118 bool useOldDateFormat() const { return m_bUseOldDateFormat
; }
119 ODBCDriver
* getDriver() const { return m_xDriver
.get();}
121 SQLHANDLE
createStatementHandle();
122 // close and free the handle and set it to SQL_NULLHANDLE
123 void freeStatementHandle(SQLHANDLE
& _pHandle
);
127 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OCONNECTION_HXX
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */