Update ooo320-m1
[ooovba.git] / connectivity / source / inc / odbc / OConnection.hxx
blob1b0339a74246a99f14ada7df5a72704bc635a6ec
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OConnection.hxx,v $
10 * $Revision: 1.24 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _CONNECTIVITY_ODBC_OCONNECTION_HXX_
31 #define _CONNECTIVITY_ODBC_OCONNECTION_HXX_
33 #include <com/sun/star/sdbc/SQLWarning.hpp>
34 #include <com/sun/star/beans/PropertyValue.hpp>
35 #include "odbc/OFunctiondefs.hxx"
36 #include "odbc/odbcbasedllapi.hxx"
37 #include "OSubComponent.hxx"
38 #include "connectivity/CommonTools.hxx"
39 #include "TConnection.hxx"
40 #include "OTypeInfo.hxx"
41 #include <cppuhelper/weakref.hxx>
42 #include "AutoRetrievingBase.hxx"
43 #include <osl/module.h>
46 #include <map>
48 namespace connectivity
50 namespace odbc
53 class OStatement_Base;
54 class ODBCDriver;
55 class ODatabaseMetaData;
57 typedef connectivity::OMetaConnection OConnection_BASE;
58 typedef ::std::vector< ::connectivity::OTypeInfo> TTypeInfoVector;
60 class OOO_DLLPUBLIC_ODBCBASE OConnection :
61 public OConnection_BASE,
62 public connectivity::OSubComponent<OConnection, OConnection_BASE>,
63 public OAutoRetrievingBase
65 friend class connectivity::OSubComponent<OConnection, OConnection_BASE>;
67 protected:
68 //====================================================================
69 // Data attributes
70 //====================================================================
71 ::std::map< SQLHANDLE,OConnection*> m_aConnections; // holds all connectionas which are need for serveral statements
72 TTypeInfoVector m_aTypeInfo; // vector containing an entry
73 // for each row returned by
74 // DatabaseMetaData.getTypeInfo.
77 ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by
78 // an operation
79 ::rtl::OUString m_sUser; // the user name
80 ODBCDriver* m_pDriver; // Pointer to the owning
81 // driver object
83 SQLHANDLE m_aConnectionHandle;
84 SQLHANDLE m_pDriverHandleCopy; // performance reason
85 sal_Int32 m_nStatementCount;
86 sal_Bool m_bClosed;
87 sal_Bool m_bUseCatalog; // should we use the catalog on filebased databases
88 sal_Bool m_bUseOldDateFormat;
89 sal_Bool m_bParameterSubstitution;
90 sal_Bool m_bIgnoreDriverPrivileges;
91 sal_Bool m_bPreventGetVersionColumns; // #i60273#
92 sal_Bool m_bReadOnly;
95 SQLRETURN OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, sal_Bool bSilent);
97 virtual OConnection* cloneConnection(); // creates a new connection
99 public:
100 oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const;
101 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);
103 OConnection(const SQLHANDLE _pDriverHandle,ODBCDriver* _pDriver);
104 // OConnection(const SQLHANDLE _pConnectionHandle);
105 virtual ~OConnection();
107 void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
109 // OComponentHelper
110 virtual void SAL_CALL disposing(void);
111 // XInterface
112 virtual void SAL_CALL release() throw();
114 // XServiceInfo
115 DECLARE_SERVICE_INFO();
116 // XConnection
117 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);
118 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);
119 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);
120 virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
121 virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
122 virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
123 virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
124 virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
125 virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
126 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);
127 virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
128 virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
129 virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
130 virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
131 virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
132 virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
133 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);
134 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);
135 // XCloseable
136 virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
137 // XWarningsSupplier
138 virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
139 virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
141 SQLHANDLE getConnection() { return m_aConnectionHandle; }
143 // should we use the catalog on filebased databases
144 inline sal_Bool isCatalogUsed() const { return m_bUseCatalog; }
145 inline sal_Bool isParameterSubstitutionEnabled() const { return m_bParameterSubstitution; }
146 inline sal_Bool isIgnoreDriverPrivilegesEnabled() const { return m_bIgnoreDriverPrivileges; }
147 inline sal_Bool preventGetVersionColumns() const { return m_bPreventGetVersionColumns; }
148 inline sal_Bool useOldDateFormat() const { return m_bUseOldDateFormat; }
149 inline SQLHANDLE getDriverHandle() const { return m_pDriverHandleCopy;}
150 inline ODBCDriver* getDriver() const { return m_pDriver;}
151 inline ::rtl::OUString getUserName() const { return m_sUser; }
153 SQLHANDLE createStatementHandle();
154 // close and free the handle and set it to SQL_NULLHANDLE
155 void freeStatementHandle(SQLHANDLE& _pHandle);
157 void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException);
158 const TTypeInfoVector& getTypeInfo() const { return m_aTypeInfo; }
162 #endif // _CONNECTIVITY_ODBC_OCONNECTION_HXX_