1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <java/lang/Object.hxx>
22 #include <com/sun/star/sdbc/XStatement.hpp>
23 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
24 #include <com/sun/star/sdbc/XMultipleResults.hpp>
25 #include <com/sun/star/sdbc/XBatchExecution.hpp>
26 #include <com/sun/star/sdbc/XCloseable.hpp>
27 #include <com/sun/star/util/XCancellable.hpp>
28 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
29 #include <comphelper/proparrhlp.hxx>
30 #include <cppuhelper/compbase.hxx>
31 #include <cppuhelper/basemutex.hxx>
32 #include <connectivity/CommonTools.hxx>
33 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <java/sql/Connection.hxx>
36 #include <java/sql/ConnectionLog.hxx>
38 namespace connectivity
41 typedef ::cppu::WeakComponentImplHelper
< css::sdbc::XStatement
,
42 css::sdbc::XWarningsSupplier
,
43 css::util::XCancellable
,
44 css::sdbc::XCloseable
,
45 css::sdbc::XGeneratedResultSet
,
46 css::sdbc::XMultipleResults
> java_sql_Statement_BASE
;
48 //************ Class: java.sql.Statement
50 class java_sql_Statement_Base
: public cppu::BaseMutex
,
51 public java_sql_Statement_BASE
,
52 public java_lang_Object
,
53 public ::cppu::OPropertySetHelper
,
54 public ::comphelper::OPropertyArrayUsageHelper
<java_sql_Statement_Base
>
58 /// @throws css::sdbc::SQLException
59 /// @throws css::uno::RuntimeException
60 sal_Int32
getQueryTimeOut();
61 /// @throws css::sdbc::SQLException
62 /// @throws css::uno::RuntimeException
63 sal_Int32
getMaxFieldSize();
64 /// @throws css::sdbc::SQLException
65 /// @throws css::uno::RuntimeException
66 sal_Int32
getMaxRows();
67 /// @throws css::sdbc::SQLException
68 /// @throws css::uno::RuntimeException
69 sal_Int32
getResultSetConcurrency();
70 /// @throws css::sdbc::SQLException
71 /// @throws css::uno::RuntimeException
72 sal_Int32
getResultSetType();
73 /// @throws css::sdbc::SQLException
74 /// @throws css::uno::RuntimeException
75 sal_Int32
getFetchDirection();
76 /// @throws css::sdbc::SQLException
77 /// @throws css::uno::RuntimeException
78 sal_Int32
getFetchSize();
79 /// @throws css::sdbc::SQLException
80 /// @throws css::uno::RuntimeException
81 OUString
getCursorName();
83 /// @throws css::sdbc::SQLException
84 /// @throws css::uno::RuntimeException
85 void setQueryTimeOut(sal_Int32 _par0
);
86 /// @throws css::sdbc::SQLException
87 /// @throws css::uno::RuntimeException
88 void setMaxFieldSize(sal_Int32 _par0
);
89 /// @throws css::sdbc::SQLException
90 /// @throws css::uno::RuntimeException
91 void setMaxRows(sal_Int32 _par0
);
92 /// @throws css::sdbc::SQLException
93 /// @throws css::uno::RuntimeException
94 void setResultSetConcurrency(sal_Int32 _par0
);
95 /// @throws css::sdbc::SQLException
96 /// @throws css::uno::RuntimeException
97 void setResultSetType(sal_Int32 _par0
);
98 /// @throws css::sdbc::SQLException
99 /// @throws css::uno::RuntimeException
100 void setFetchDirection(sal_Int32 _par0
);
101 /// @throws css::sdbc::SQLException
102 /// @throws css::uno::RuntimeException
103 void setFetchSize(sal_Int32 _par0
);
104 /// @throws css::sdbc::SQLException
105 /// @throws css::uno::RuntimeException
106 void setCursorName(const OUString
&_par0
);
107 /// @throws css::sdbc::SQLException
108 /// @throws css::uno::RuntimeException
109 void setEscapeProcessing(bool _par0
);
112 css::uno::Reference
< css::sdbc::XStatement
> m_xGeneratedStatement
;
113 rtl::Reference
<java_sql_Connection
> m_pConnection
;
114 java::sql::ConnectionLog m_aLogger
;
115 OUString m_sSqlStatement
;
117 sal_Int32 m_nResultSetConcurrency
;
118 sal_Int32 m_nResultSetType
;
119 bool m_bEscapeProcessing
;
122 // Static data for the class
123 static jclass theClass
;
125 // OPropertyArrayUsageHelper
126 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const override
;
127 // OPropertySetHelper
128 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
130 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
131 css::uno::Any
& rConvertedValue
,
132 css::uno::Any
& rOldValue
,
134 const css::uno::Any
& rValue
137 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
139 const css::uno::Any
& rValue
142 virtual void SAL_CALL
getFastPropertyValue(
143 css::uno::Any
& rValue
,
147 virtual void createStatement(JNIEnv
* _pEnv
) = 0;
149 virtual ~java_sql_Statement_Base() override
;
151 sal_Int32
impl_getProperty(const char* _pMethodName
, jmethodID
& _inout_MethodID
);
152 sal_Int32
impl_getProperty(const char* _pMethodName
, jmethodID
& _inout_MethodID
,sal_Int32 _nDefault
);
155 virtual jclass
getMyClass() const override
;
157 // A ctor that is needed for returning the object
158 java_sql_Statement_Base( JNIEnv
* pEnv
, java_sql_Connection
& _rCon
);
160 sal_Int32
getStatementObjectID() const { return m_aLogger
.getObjectID(); }
163 virtual void SAL_CALL
disposing() override
;
165 virtual void SAL_CALL
acquire() noexcept override
;
166 virtual void SAL_CALL
release() noexcept override
;
167 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
169 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
172 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
174 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
executeQuery( const OUString
& sql
) override
;
175 virtual sal_Int32 SAL_CALL
executeUpdate( const OUString
& sql
) override
;
176 virtual sal_Bool SAL_CALL
execute( const OUString
& sql
) override
;
177 virtual css::uno::Reference
< css::sdbc::XConnection
> SAL_CALL
getConnection( ) override
;
179 virtual css::uno::Any SAL_CALL
getWarnings( ) override
;
180 virtual void SAL_CALL
clearWarnings( ) override
;
182 virtual void SAL_CALL
cancel( ) override
;
184 virtual void SAL_CALL
close( ) override
;
186 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
getResultSet( ) override
;
187 virtual sal_Int32 SAL_CALL
getUpdateCount( ) override
;
188 virtual sal_Bool SAL_CALL
getMoreResults( ) override
;
189 //XGeneratedResultSet
190 virtual css::uno::Reference
< css::sdbc::XResultSet
> SAL_CALL
getGeneratedValues( ) override
;
193 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
196 class OStatement_BASE2
: public java_sql_Statement_Base
200 OStatement_BASE2(JNIEnv
* pEnv
, java_sql_Connection
& _rCon
) : java_sql_Statement_Base( pEnv
, _rCon
) {}
203 virtual void SAL_CALL
disposing() override
;
206 class java_sql_Statement
: public OStatement_BASE2
,
207 public css::sdbc::XBatchExecution
,
208 public css::lang::XServiceInfo
211 // Static data for the class
212 static jclass theClass
;
214 virtual void createStatement(JNIEnv
* _pEnv
) override
;
216 virtual ~java_sql_Statement() override
;
218 DECLARE_SERVICE_INFO();
219 virtual jclass
getMyClass() const override
;
221 // A ctor that is needed for returning the object
222 java_sql_Statement( JNIEnv
* pEnv
, java_sql_Connection
& _rCon
) : OStatement_BASE2( pEnv
, _rCon
){};
224 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
225 virtual void SAL_CALL
acquire() noexcept override
;
226 virtual void SAL_CALL
release() noexcept override
;
228 virtual void SAL_CALL
addBatch( const OUString
& sql
) override
;
229 virtual void SAL_CALL
clearBatch( ) override
;
230 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
executeBatch( ) override
;
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */