1 /*************************************************************************
3 * $RCSfile: SConnection.hxx,v $
7 * last change: $Author: rt $ $Date: 2008-04-10 16:31:02 $
9 * The Contents of this file are made available subject to the terms of
12 * Copyright (c) 2003 by Sun Microsystems, Inc.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *************************************************************************/
41 #ifndef CONNECTIVITY_SCONNECTION_HXX
42 #define CONNECTIVITY_SCONNECTION_HXX
44 #include <com/sun/star/sdbc/SQLWarning.hpp>
45 #include <com/sun/star/beans/PropertyValue.hpp>
46 #include "OSubComponent.hxx"
47 #include "OTypeInfo.hxx"
48 #include <com/sun/star/lang/DisposedException.hpp>
49 #include <com/sun/star/lang/XServiceInfo.hpp>
50 #include <com/sun/star/lang/XUnoTunnel.hpp>
51 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
52 #include <com/sun/star/sdbc/XConnection.hpp>
53 #include <cppuhelper/compbase3.hxx>
54 #include <cppuhelper/weakref.hxx>
58 namespace connectivity
63 typedef ::cppu::WeakComponentImplHelper3
< ::com::sun::star::sdbc::XConnection
,
64 ::com::sun::star::sdbc::XWarningsSupplier
,
65 ::com::sun::star::lang::XServiceInfo
66 > OMetaConnection_BASE
;
68 class OStatement_Base
;
70 class ODatabaseMetaData
;
72 typedef OMetaConnection_BASE OConnection_BASE
; // implements basics and text encoding
73 typedef ::std::vector
< ::connectivity::OTypeInfo
> TTypeInfoVector
;
74 typedef std::vector
< ::com::sun::star::uno::WeakReferenceHelper
> OWeakRefArray
;
76 class OConnection
: public OBase_Mutex
,
77 public OConnection_BASE
,
78 public connectivity::skeleton::OSubComponent
<OConnection
, OConnection_BASE
>
80 friend class connectivity::skeleton::OSubComponent
<OConnection
, OConnection_BASE
>;
84 rtl_TextEncoding m_nTextEncoding
; // the encoding which is used for all text conversions
85 //====================================================================
87 //====================================================================
88 TTypeInfoVector m_aTypeInfo
; // vector containing an entry
89 // for each row returned by
90 // DatabaseMetaData.getTypeInfo.
91 ::com::sun::star::uno::WeakReference
< ::com::sun::star::sdbc::XDatabaseMetaData
> m_xMetaData
;
93 OWeakRefArray m_aStatements
; // vector containing a list
94 // of all the Statement objects
95 // for this Connection
97 ::com::sun::star::sdbc::SQLWarning m_aLastWarning
; // Last SQLWarning generated by
99 ::rtl::OUString m_aURL
; // URL of connection
100 ::rtl::OUString m_sUser
; // the user name
101 SkeletonDriver
* m_pDriver
; // Pointer to the owning
105 sal_Bool m_bUseCatalog
; // should we use the catalog on filebased databases
106 sal_Bool m_bUseOldDateFormat
;
109 void buildTypeInfo() throw( ::com::sun::star::sdbc::SQLException
);
112 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
);
114 OConnection(SkeletonDriver
* _pDriver
);
115 virtual ~OConnection();
117 void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException
);
120 virtual void SAL_CALL
disposing(void);
122 virtual void SAL_CALL
release() throw();
125 DECLARE_SERVICE_INFO();
127 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
);
128 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
);
129 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
);
130 virtual ::rtl::OUString SAL_CALL
nativeSQL( const ::rtl::OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
131 virtual void SAL_CALL
setAutoCommit( sal_Bool autoCommit
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
132 virtual sal_Bool SAL_CALL
getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
133 virtual void SAL_CALL
commit( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
134 virtual void SAL_CALL
rollback( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
135 virtual sal_Bool SAL_CALL
isClosed( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
136 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
);
137 virtual void SAL_CALL
setReadOnly( sal_Bool readOnly
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
138 virtual sal_Bool SAL_CALL
isReadOnly( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
139 virtual void SAL_CALL
setCatalog( const ::rtl::OUString
& catalog
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
140 virtual ::rtl::OUString SAL_CALL
getCatalog( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
141 virtual void SAL_CALL
setTransactionIsolation( sal_Int32 level
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
142 virtual sal_Int32 SAL_CALL
getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
143 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
);
144 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
);
146 virtual void SAL_CALL
close( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
148 virtual ::com::sun::star::uno::Any SAL_CALL
getWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
149 virtual void SAL_CALL
clearWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
152 // should we use the catalog on filebased databases
153 inline sal_Bool
isCatalogUsed() const { return m_bUseCatalog
; }
154 inline ::rtl::OUString
getUserName() const { return m_sUser
; }
155 inline SkeletonDriver
* getDriver() const { return m_pDriver
;}
156 inline rtl_TextEncoding
getTextEncoding() const { return m_nTextEncoding
; }
160 #endif // CONNECTIVITY_SCONNECTION_HXX