xref: /AOO41X/main/mysqlc/source/mysqlc_preparedstatement.hxx (revision 079eb5772d0a9e49bbf5c2cd738fc5b5d43e5181)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef CONNECTIVITY_SPREPAREDSTATEMENT_HXX
23 #define CONNECTIVITY_SPREPAREDSTATEMENT_HXX
24 #include "mysqlc_statement.hxx"
25 #include "mysqlc_resultset.hxx"
26 
27 #ifndef _COM_SUN_STAR_SDBC_XPREPAREDSTATEMENT_HPP_
28 #include <com/sun/star/sdbc/XPreparedStatement.hpp>
29 #endif
30 #ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_
31 #include <com/sun/star/sdbc/XParameters.hpp>
32 #endif
33 #ifndef _COM_SUN_STAR_SDBC_XRESULTSETMETADATASUPPLIER_HPP_
34 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_SDBC_XPREPAREDBATCHEXECUTION_HPP_
37 #include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
40 #include <com/sun/star/io/XInputStream.hpp>
41 #endif
42 
43 #include <preextstl.h>
44 #include <cppconn/prepared_statement.h>
45 #include <postextstl.h>
46 
47 namespace connectivity
48 {
49     namespace mysqlc
50     {
51         using ::com::sun::star::uno::Reference;
52         using ::com::sun::star::uno::Any;
53         using ::com::sun::star::uno::Type;
54         using ::com::sun::star::sdbc::SQLException;
55         using ::com::sun::star::uno::RuntimeException;
56         using ::com::sun::star::sdbc::XResultSetMetaData;
57 
58         class OBoundParam;
59         typedef ::cppu::ImplHelper5<    ::com::sun::star::sdbc::XPreparedStatement,
60                                         ::com::sun::star::sdbc::XParameters,
61                                         ::com::sun::star::sdbc::XPreparedBatchExecution,
62                                         ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
63                                         ::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE;
64 
65         class OPreparedStatement :  public OCommonStatement,
66                                     public OPreparedStatement_BASE
67         {
68         protected:
69             unsigned int        m_paramCount;   // number of placeholders
70             sal_Int32           m_nNumParams;   // Number of parameter markers for the prepared statement
71             Reference< XResultSetMetaData > m_xMetaData;
72 
73             void checkParameterIndex(sal_Int32 parameter);
74 
75         protected:
76             void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue)
77                                                                                     throw (::com::sun::star::uno::Exception);
78             virtual ~OPreparedStatement();
79         public:
80             DECLARE_SERVICE_INFO();
81             OPreparedStatement(OConnection* _pConnection, sql::PreparedStatement * cppPrepStmt);
82 
83             //XInterface
84             Any SAL_CALL queryInterface(const Type & rType) throw(RuntimeException);
85             void SAL_CALL acquire() throw();
86             void SAL_CALL release() throw();
87 
88             //XTypeProvider
89             ::com::sun::star::uno::Sequence< Type > SAL_CALL getTypes()
90                                                                                     throw(RuntimeException);
91 
92             // XPreparedStatement
93             Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery() throw(SQLException, RuntimeException);
94             sal_Int32 SAL_CALL executeUpdate() throw(SQLException, RuntimeException);
95             sal_Bool SAL_CALL execute() throw(SQLException, RuntimeException);
96             Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection() throw(SQLException, RuntimeException);
97 
98             // XStatement
99             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(const OUString& sql)
100                                                 throw(SQLException, RuntimeException);
101             sal_Int32 SAL_CALL executeUpdate(const OUString& sql)
102                                                 throw(SQLException, RuntimeException);
103             sal_Bool SAL_CALL execute( const OUString& sql )
104                                                 throw(SQLException, RuntimeException);
105 
106             // XParameters
107             void SAL_CALL setNull(sal_Int32 parameter, sal_Int32 sqlType)           throw(SQLException, RuntimeException);
108 
109             void SAL_CALL setObjectNull(sal_Int32 parameter, sal_Int32 sqlType, const OUString& typeName)
110                                                                                     throw(SQLException, RuntimeException);
111 
112             void SAL_CALL setBoolean(sal_Int32 parameter, sal_Bool x)               throw(SQLException, RuntimeException);
113 
114             void SAL_CALL setByte(sal_Int32 parameter, sal_Int8 x)                  throw(SQLException, RuntimeException);
115 
116             void SAL_CALL setShort(sal_Int32 parameter, sal_Int16 x)                throw(SQLException, RuntimeException);
117 
118             void SAL_CALL setInt(sal_Int32 parameter, sal_Int32 x)                  throw(SQLException, RuntimeException);
119 
120             void SAL_CALL setLong(sal_Int32 parameter, sal_Int64 x)                 throw(SQLException, RuntimeException);
121 
122             void SAL_CALL setFloat(sal_Int32 parameter, float x)                    throw(SQLException, RuntimeException);
123 
124             void SAL_CALL setDouble(sal_Int32 parameter, double x)                  throw(SQLException, RuntimeException);
125 
126             void SAL_CALL setString(sal_Int32 parameter, const OUString& x)         throw(SQLException, RuntimeException);
127 
128             void SAL_CALL setBytes(sal_Int32 parameter, const ::com::sun::star::uno::Sequence< sal_Int8 >& x)
129                                                                                     throw(SQLException, RuntimeException);
130 
131             void SAL_CALL setDate(sal_Int32 parameter, const ::com::sun::star::util::Date& x)
132                                                                                     throw(SQLException, RuntimeException);
133 
134             void SAL_CALL setTime(sal_Int32 parameter, const ::com::sun::star::util::Time& x)
135                                                                                     throw(SQLException, RuntimeException);
136             void SAL_CALL setTimestamp(sal_Int32 parameter, const ::com::sun::star::util::DateTime& x)
137                                                                                     throw(SQLException, RuntimeException);
138 
139             void SAL_CALL setBinaryStream(sal_Int32 parameter, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length)
140                                                                                     throw(SQLException, RuntimeException);
141 
142             void SAL_CALL setCharacterStream(sal_Int32 parameter, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length)
143                                                                                     throw(SQLException, RuntimeException);
144 
145             void SAL_CALL setObject(sal_Int32 parameter, const Any& x)              throw(SQLException, RuntimeException);
146 
147             void SAL_CALL setObjectWithInfo(sal_Int32 parameter, const Any& x, sal_Int32 targetSqlType, sal_Int32 scale)
148                                                                                     throw(SQLException, RuntimeException);
149 
150             void SAL_CALL setRef(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XRef >& x)
151                                                                                     throw(SQLException, RuntimeException);
152 
153             void SAL_CALL setBlob(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XBlob >& x)
154                                                                                     throw(SQLException, RuntimeException);
155 
156             void SAL_CALL setClob(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XClob >& x)
157                                                                                     throw(SQLException, RuntimeException);
158 
159             void SAL_CALL setArray(sal_Int32 parameter, const Reference< ::com::sun::star::sdbc::XArray >& x)
160                                                                                     throw(SQLException, RuntimeException);
161 
162             void SAL_CALL clearParameters() throw(SQLException, RuntimeException);
163 
164             // XPreparedBatchExecution
165             void SAL_CALL addBatch() throw(SQLException, RuntimeException);
166             void SAL_CALL clearBatch() throw(SQLException, RuntimeException);
167             ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch()    throw(SQLException, RuntimeException);
168 
169             // XCloseable
170             void SAL_CALL close() throw(SQLException, RuntimeException);
171 
172             // XResultSetMetaDataSupplier
173             Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData()
174                                                                                     throw(SQLException, RuntimeException);
175         };
176     } /* mysqlc */
177 } /* connectivity */
178 #endif // CONNECTIVITY_SPREPAREDSTATEMENT_HXX
179 
180 /*
181  * Local variables:
182  * tab-width: 4
183  * c-basic-offset: 4
184  * End:
185  * vim600: noet sw=4 ts=4 fdm=marker
186  * vim<600: noet sw=4 ts=4
187  */
188 
189