1*34dd1e25SAndrew Rist /**************************************************************
2*34dd1e25SAndrew Rist  *
3*34dd1e25SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*34dd1e25SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*34dd1e25SAndrew Rist  * distributed with this work for additional information
6*34dd1e25SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*34dd1e25SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*34dd1e25SAndrew Rist  * "License"); you may not use this file except in compliance
9*34dd1e25SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*34dd1e25SAndrew Rist  *
11*34dd1e25SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*34dd1e25SAndrew Rist  *
13*34dd1e25SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*34dd1e25SAndrew Rist  * software distributed under the License is distributed on an
15*34dd1e25SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*34dd1e25SAndrew Rist  * KIND, either express or implied.  See the License for the
17*34dd1e25SAndrew Rist  * specific language governing permissions and limitations
18*34dd1e25SAndrew Rist  * under the License.
19*34dd1e25SAndrew Rist  *
20*34dd1e25SAndrew Rist  *************************************************************/
21*34dd1e25SAndrew Rist 
22*34dd1e25SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef CONNECTIVITY_SCONNECTION_HXX
25cdf0e10cSrcweir #define CONNECTIVITY_SCONNECTION_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
29cdf0e10cSrcweir #include "OSubComponent.hxx"
30cdf0e10cSrcweir #include "OTypeInfo.hxx"
31cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
32cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
34cdf0e10cSrcweir #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
35cdf0e10cSrcweir #include <com/sun/star/sdbc/XConnection.hpp>
36cdf0e10cSrcweir #include <cppuhelper/compbase3.hxx>
37cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <map>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace connectivity
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 	namespace skeleton
44cdf0e10cSrcweir 	{
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 		typedef ::cppu::WeakComponentImplHelper3<   ::com::sun::star::sdbc::XConnection,
47cdf0e10cSrcweir 												::com::sun::star::sdbc::XWarningsSupplier,
48cdf0e10cSrcweir                                                 ::com::sun::star::lang::XServiceInfo
49cdf0e10cSrcweir 											> OMetaConnection_BASE;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 		class OStatement_Base;
52cdf0e10cSrcweir 		class SkeletonDriver;
53cdf0e10cSrcweir 		class ODatabaseMetaData;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 		typedef OMetaConnection_BASE				OConnection_BASE; // implements basics and text encoding
56cdf0e10cSrcweir 		typedef ::std::vector< ::connectivity::OTypeInfo>	TTypeInfoVector;
57cdf0e10cSrcweir 		typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 		class OConnection : public OBase_Mutex,
60cdf0e10cSrcweir 							public OConnection_BASE,
61cdf0e10cSrcweir 							public connectivity::skeleton::OSubComponent<OConnection, OConnection_BASE>
62cdf0e10cSrcweir 		{
63cdf0e10cSrcweir 			friend class connectivity::skeleton::OSubComponent<OConnection, OConnection_BASE>;
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 		protected:
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 			rtl_TextEncoding						m_nTextEncoding; // the encoding which is used for all text conversions
68cdf0e10cSrcweir 			//====================================================================
69cdf0e10cSrcweir 			// Data attributes
70cdf0e10cSrcweir 			//====================================================================
71cdf0e10cSrcweir 			TTypeInfoVector							m_aTypeInfo;	//	vector containing an entry
72cdf0e10cSrcweir 																	//  for each row returned by
73cdf0e10cSrcweir 																	//  DatabaseMetaData.getTypeInfo.
74cdf0e10cSrcweir             ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 			OWeakRefArray							m_aStatements;	//	vector containing a list
77cdf0e10cSrcweir 														//  of all the Statement objects
78cdf0e10cSrcweir 														//  for this Connection
79cdf0e10cSrcweir 
80cdf0e10cSrcweir             ::com::sun::star::sdbc::SQLWarning      m_aLastWarning; //      Last SQLWarning generated by
81cdf0e10cSrcweir 														//  an operation
82cdf0e10cSrcweir 			::rtl::OUString							m_aURL;			//	URL of connection
83cdf0e10cSrcweir 			::rtl::OUString							m_sUser;		// the user name
84cdf0e10cSrcweir 			SkeletonDriver*							m_pDriver;		//	Pointer to the owning
85cdf0e10cSrcweir 																	//  driver object
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 			sal_Bool								m_bClosed;
88cdf0e10cSrcweir 			sal_Bool								m_bUseCatalog;	// should we use the catalog on filebased databases
89cdf0e10cSrcweir 			sal_Bool								m_bUseOldDateFormat;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir             void                    buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException);
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 		public:
95cdf0e10cSrcweir             virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 			OConnection(SkeletonDriver*	_pDriver);
98cdf0e10cSrcweir 			virtual ~OConnection();
99cdf0e10cSrcweir 
100cdf0e10cSrcweir             void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 			// OComponentHelper
103cdf0e10cSrcweir 			virtual void SAL_CALL disposing(void);
104cdf0e10cSrcweir 			// XInterface
105cdf0e10cSrcweir 			virtual void SAL_CALL release() throw();
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 			// XServiceInfo
108cdf0e10cSrcweir 			DECLARE_SERVICE_INFO();
109cdf0e10cSrcweir 			// XConnection
110cdf0e10cSrcweir             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);
111cdf0e10cSrcweir             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);
112cdf0e10cSrcweir             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);
113cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir             virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
115cdf0e10cSrcweir             virtual sal_Bool SAL_CALL getAutoCommit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
116cdf0e10cSrcweir             virtual void SAL_CALL commit(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
117cdf0e10cSrcweir             virtual void SAL_CALL rollback(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
118cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isClosed(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
119cdf0e10cSrcweir             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);
120cdf0e10cSrcweir             virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
121cdf0e10cSrcweir             virtual sal_Bool SAL_CALL isReadOnly(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
122cdf0e10cSrcweir             virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir             virtual ::rtl::OUString SAL_CALL getCatalog(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
124cdf0e10cSrcweir             virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
125cdf0e10cSrcweir             virtual sal_Int32 SAL_CALL getTransactionIsolation(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
126cdf0e10cSrcweir             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);
127cdf0e10cSrcweir             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);
128cdf0e10cSrcweir 			// XCloseable
129cdf0e10cSrcweir 			virtual void SAL_CALL close(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
130cdf0e10cSrcweir 			// XWarningsSupplier
131cdf0e10cSrcweir 			virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
132cdf0e10cSrcweir 			virtual void SAL_CALL clearWarnings(  ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
133cdf0e10cSrcweir 			//
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 			// should we use the catalog on filebased databases
isCatalogUsed() const136cdf0e10cSrcweir 			inline sal_Bool			isCatalogUsed()		const { return m_bUseCatalog; }
getUserName() const137cdf0e10cSrcweir 			inline ::rtl::OUString	getUserName()		const { return m_sUser; }
getDriver() const138cdf0e10cSrcweir 			inline SkeletonDriver*	getDriver()			const { return m_pDriver;}
getTextEncoding() const139cdf0e10cSrcweir 			inline rtl_TextEncoding getTextEncoding()	const { return m_nTextEncoding; }
140cdf0e10cSrcweir 		};
141cdf0e10cSrcweir 	}
142cdf0e10cSrcweir }
143cdf0e10cSrcweir #endif // CONNECTIVITY_SCONNECTION_HXX
144cdf0e10cSrcweir 
145