1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * The Contents of this file are made available subject to the terms of
7 * Copyright 2000, 2010 Oracle and/or its affiliates.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
32 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *************************************************************************/
36 #ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
37 #define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
39 #include <com/sun/star/sdbc/XStatement.hpp>
40 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
41 #include <com/sun/star/sdbc/XMultipleResults.hpp>
42 #include <com/sun/star/sdbc/XBatchExecution.hpp>
43 #include <com/sun/star/sdbc/XCloseable.hpp>
44 #include <com/sun/star/sdbc/SQLWarning.hpp>
45 #include <com/sun/star/util/XCancellable.hpp>
46 #include <cppuhelper/compbase5.hxx>
47 #include "SConnection.hxx"
49 #include "OSubComponent.hxx"
50 #include <com/sun/star/lang/XServiceInfo.hpp>
52 namespace connectivity
57 typedef ::cppu::WeakComponentImplHelper5
< ::com::sun::star::sdbc::XStatement
,
58 ::com::sun::star::sdbc::XWarningsSupplier
,
59 ::com::sun::star::util::XCancellable
,
60 ::com::sun::star::sdbc::XCloseable
,
61 ::com::sun::star::sdbc::XMultipleResults
> OStatement_BASE
;
63 // A base class for the normal statement and for the prepared statement
64 class OStatement_Base
: public OBase_Mutex
,
65 public OStatement_BASE
,
66 public ::cppu::OPropertySetHelper
,
67 public OPropertyArrayUsageHelper
<OStatement_Base
>
70 ::com::sun::star::sdbc::SQLWarning m_aLastWarning
;
72 ::com::sun::star::uno::WeakReference
< ::com::sun::star::sdbc::XResultSet
> m_xResultSet
; // The last ResultSet created
75 ::std::vector
< ::rtl::OUString
> m_aBatchVector
;
77 OConnection
* m_pConnection
; // The owning Connection object
80 void disposeResultSet();
82 // OPropertyArrayUsageHelper
83 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const;
85 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper();
86 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
87 ::com::sun::star::uno::Any
& rConvertedValue
,
88 ::com::sun::star::uno::Any
& rOldValue
,
90 const ::com::sun::star::uno::Any
& rValue
)
91 throw (::com::sun::star::lang::IllegalArgumentException
);
92 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
94 const ::com::sun::star::uno::Any
& rValue
) throw (::com::sun::star::uno::Exception
);
95 virtual void SAL_CALL
getFastPropertyValue(
96 ::com::sun::star::uno::Any
& rValue
,
97 sal_Int32 nHandle
) const;
98 virtual ~OStatement_Base();
101 ::cppu::OBroadcastHelper
& rBHelper
;
102 OStatement_Base(OConnection
* _pConnection
);
103 using OStatement_BASE::operator ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>;
106 virtual void SAL_CALL
disposing(){OStatement_BASE::disposing();}
108 virtual void SAL_CALL
release() throw();
109 virtual void SAL_CALL
acquire() throw();
111 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
);
113 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
);
116 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
118 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> SAL_CALL
executeQuery( const ::rtl::OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
) ;
119 virtual sal_Int32 SAL_CALL
executeUpdate( const ::rtl::OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
) ;
120 virtual sal_Bool SAL_CALL
execute( const ::rtl::OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
) ;
121 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> SAL_CALL
getConnection( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
) ;
123 virtual ::com::sun::star::uno::Any SAL_CALL
getWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
124 virtual void SAL_CALL
clearWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
126 virtual void SAL_CALL
cancel( ) throw(::com::sun::star::uno::RuntimeException
);
128 virtual void SAL_CALL
close( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
130 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> SAL_CALL
getResultSet( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
131 virtual sal_Int32 SAL_CALL
getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
132 virtual sal_Bool SAL_CALL
getMoreResults( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
135 OConnection
* getOwnConnection() const { return m_pConnection
;}
138 class OStatement_BASE2
:public OStatement_Base
139 ,public OSubComponent
<OStatement_BASE2
, OStatement_BASE
>
142 friend class OSubComponent
<OStatement_BASE2
, OStatement_BASE
>;
144 OStatement_BASE2(OConnection
* _pConnection
) : OStatement_Base(_pConnection
),
145 OSubComponent
<OStatement_BASE2
, OStatement_BASE
>((::cppu::OWeakObject
*)_pConnection
, this){}
147 virtual void SAL_CALL
disposing();
149 virtual void SAL_CALL
release() throw();
152 class OStatement
: public OStatement_BASE2
,
153 public ::com::sun::star::sdbc::XBatchExecution
,
154 public ::com::sun::star::lang::XServiceInfo
157 virtual ~OStatement(){}
159 // a constructor, which is required for returning objects:
160 OStatement( OConnection
* _pConnection
) : OStatement_BASE2( _pConnection
){}
161 DECLARE_SERVICE_INFO();
163 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
);
164 virtual void SAL_CALL
acquire() throw();
165 virtual void SAL_CALL
release() throw();
167 virtual void SAL_CALL
addBatch( const ::rtl::OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
168 virtual void SAL_CALL
clearBatch( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
169 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
executeBatch( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
174 #endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */