xref: /trunk/main/mysqlc/source/mysqlc_preparedstatement.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * Copyright 2008 by Sun Microsystems, Inc.
5 *
6 * OpenOffice.org - a multi-platform office productivity suite
7 *
8 * $RCSfile: mysqlc_preparedstatement.hxx,v $
9 *
10 * $Revision: 1.1.2.4 $
11 *
12 * This file is part of OpenOffice.org.
13 *
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.
17 *
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).
23 *
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.
28 ************************************************************************/
29 
30 #ifndef CONNECTIVITY_SPREPAREDSTATEMENT_HXX
31 #define CONNECTIVITY_SPREPAREDSTATEMENT_HXX
32 #include "mysqlc_statement.hxx"
33 #include "mysqlc_resultset.hxx"
34 
35 #ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
36 #include <com/sun/star/sdbc/XPreparedStatement.hpp>
37 #endif
38 #ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
39 #include <com/sun/star/sdbc/XParameters.hpp>
40 #endif
41 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
42 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
43 #endif
44 #ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HPP_
45 #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
46 #endif
47 #ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
48 #include <com/sun/star/io/XInputStream.hpp>
49 #endif
50 
51 #include <preextstl.h>
52 #include <cppconn/prepared_statement.h>
53 #include <postextstl.h>
54 
55 namespace connectivity
56 {
57     namespace mysqlc
58     {
59         using ::com::sun::star::uno::Reference;
60         using ::com::sun::star::uno::Any;
61         using ::com::sun::star::uno::Type;
62         using ::com::sun::star::sdbc::SQLException;
63         using ::com::sun::star::uno::RuntimeException;
64         using ::com::sun::star::sdbc::XResultSetMetaData;
65 
66         class OBoundParam;
67         typedef ::cppu::ImplHelper5<    ::com::sun::star::sdbc::XPreparedStatement,
68                                         ::com::sun::star::sdbc::XParameters,
69                                         ::com::sun::star::sdbc::XPreparedBatchExecution,
70                                         ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
71                                         ::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE;
72 
73         class OPreparedStatement :  public OCommonStatement,
74                                     public OPreparedStatement_BASE
75         {
76         protected:
77             unsigned int        m_paramCount;   // number of placeholders
78             sal_Int32           m_nNumParams;   // Number of parameter markers for the prepared statement
79             Reference< XResultSetMetaData > m_xMetaData;
80 
81             void checkParameterIndex(sal_Int32 parameter);
82 
83         protected:
84             void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue)
85                                                                                     throw (::com::sun::star::uno::Exception);
86             virtual ~OPreparedStatement();
87         public:
88             DECLARE_SERVICE_INFO();
89             OPreparedStatement(OConnection* _pConnection, sql::PreparedStatement * cppPrepStmt);
90 
91             //XInterface
92             Any SAL_CALL queryInterface(const Type & rType) throw(RuntimeException);
93             void SAL_CALL acquire() throw();
94             void SAL_CALL release() throw();
95 
96             //XTypeProvider
97             ::com::sun::star::uno::Sequence< Type > SAL_CALL getTypes()
98                                                                                     throw(RuntimeException);
99 
100             // XPreparedStatement
101             Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery() throw(SQLException, RuntimeException);
102             sal_Int32 SAL_CALL executeUpdate() throw(SQLException, RuntimeException);
103             sal_Bool SAL_CALL execute() throw(SQLException, RuntimeException);
104             Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection() throw(SQLException, RuntimeException);
105 
106             // XStatement
107             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(const OUString& sql)
108                                                 throw(SQLException, RuntimeException);
109             sal_Int32 SAL_CALL executeUpdate(const OUString& sql)
110                                                 throw(SQLException, RuntimeException);
111             sal_Bool SAL_CALL execute( const OUString& sql )
112                                                 throw(SQLException, RuntimeException);
113 
114             // XParameters
115             void SAL_CALL setNull(sal_Int32 parameter, sal_Int32 sqlType)           throw(SQLException, RuntimeException);
116 
117             void SAL_CALL setObjectNull(sal_Int32 parameter, sal_Int32 sqlType, const OUString& typeName)
118                                                                                     throw(SQLException, RuntimeException);
119 
120             void SAL_CALL setBoolean(sal_Int32 parameter, sal_Bool x)               throw(SQLException, RuntimeException);
121 
122             void SAL_CALL setByte(sal_Int32 parameter, sal_Int8 x)                  throw(SQLException, RuntimeException);
123 
124             void SAL_CALL setShort(sal_Int32 parameter, sal_Int16 x)                throw(SQLException, RuntimeException);
125 
126             void SAL_CALL setInt(sal_Int32 parameter, sal_Int32 x)                  throw(SQLException, RuntimeException);
127 
128             void SAL_CALL setLong(sal_Int32 parameter, sal_Int64 x)                 throw(SQLException, RuntimeException);
129 
130             void SAL_CALL setFloat(sal_Int32 parameter, float x)                    throw(SQLException, RuntimeException);
131 
132             void SAL_CALL setDouble(sal_Int32 parameter, double x)                  throw(SQLException, RuntimeException);
133 
134             void SAL_CALL setString(sal_Int32 parameter, const OUString& x)         throw(SQLException, RuntimeException);
135 
136             void SAL_CALL setBytes(sal_Int32 parameter, const ::com::sun::star::uno::Sequence< sal_Int8 >& x)
137                                                                                     throw(SQLException, RuntimeException);
138 
139             void SAL_CALL setDate(sal_Int32 parameter, const ::com::sun::star::util::Date& x)
140                                                                                     throw(SQLException, RuntimeException);
141 
142             void SAL_CALL setTime(sal_Int32 parameter, const ::com::sun::star::util::Time& x)
143                                                                                     throw(SQLException, RuntimeException);
144             void SAL_CALL setTimestamp(sal_Int32 parameter, const ::com::sun::star::util::DateTime& x)
145                                                                                     throw(SQLException, RuntimeException);
146 
147             void SAL_CALL setBinaryStream(sal_Int32 parameter, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length)
148                                                                                     throw(SQLException, RuntimeException);
149 
150             void SAL_CALL setCharacterStream(sal_Int32 parameter, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length)
151                                                                                     throw(SQLException, RuntimeException);
152 
153             void SAL_CALL setObject(sal_Int32 parameter, const Any& x)              throw(SQLException, RuntimeException);
154 
155             void SAL_CALL setObjectWithInfo(sal_Int32 parameter, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale)
156                                                                                     throw(SQLException, RuntimeException);
157 
158             void SAL_CALL setRef(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XRef >& x)
159                                                                                     throw(SQLException, RuntimeException);
160 
161             void SAL_CALL setBlob(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XBlob >& x)
162                                                                                     throw(SQLException, RuntimeException);
163 
164             void SAL_CALL setClob(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XClob >& x)
165                                                                                     throw(SQLException, RuntimeException);
166 
167             void SAL_CALL setArray(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XArray >& x)
168                                                                                     throw(SQLException, RuntimeException);
169 
170             void SAL_CALL clearParameters() throw(SQLException, RuntimeException);
171 
172             // XPreparedBatchExecution
173             void SAL_CALL addBatch() throw(SQLException, RuntimeException);
174             void SAL_CALL clearBatch() throw(SQLException, RuntimeException);
175             ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch()    throw(SQLException, RuntimeException);
176 
177             // XCloseable
178             void SAL_CALL close() throw(SQLException, RuntimeException);
179 
180             // XResultSetMetaDataSupplier
181             Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData()
182                                                                                     throw(SQLException, RuntimeException);
183         };
184     } /* mysqlc */
185 } /* connectivity */
186 #endif // CONNECTIVITY_SPREPAREDSTATEMENT_HXX
187 
188 /*
189  * Local variables:
190  * tab-width: 4
191  * c-basic-offset: 4
192  * End:
193  * vim600: noet sw=4 ts=4 fdm=marker
194  * vim<600: noet sw=4 ts=4
195  */
196 
197