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 .
19 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_JSTATEMENT_HXX
20 #define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_JSTATEMENT_HXX
22 #include "java/lang/Object.hxx"
23 #include <com/sun/star/sdbc/XStatement.hpp>
24 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
25 #include <com/sun/star/sdbc/XMultipleResults.hpp>
26 #include <com/sun/star/sdbc/XBatchExecution.hpp>
27 #include <com/sun/star/sdbc/XCloseable.hpp>
28 #include <com/sun/star/util/XCancellable.hpp>
29 #include <com/sun/star/sdbc/XGeneratedResultSet.hpp>
30 #include <comphelper/proparrhlp.hxx>
31 #include <cppuhelper/compbase6.hxx>
32 #include <comphelper/uno3.hxx>
33 #include <connectivity/CommonTools.hxx>
34 #include <connectivity/OSubComponent.hxx>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <comphelper/broadcasthelper.hxx>
38 #include <java/sql/Connection.hxx>
39 #include "java/sql/ConnectionLog.hxx"
41 namespace connectivity
44 typedef ::cppu::WeakComponentImplHelper6
< ::com::sun::star::sdbc::XStatement
,
45 ::com::sun::star::sdbc::XWarningsSupplier
,
46 ::com::sun::star::util::XCancellable
,
47 ::com::sun::star::sdbc::XCloseable
,
48 ::com::sun::star::sdbc::XGeneratedResultSet
,
49 ::com::sun::star::sdbc::XMultipleResults
> java_sql_Statement_BASE
;
51 //************ Class: java.sql.Statement
53 class java_sql_Statement_Base
: public comphelper::OBaseMutex
,
54 public java_sql_Statement_BASE
,
55 public java_lang_Object
,
56 public ::cppu::OPropertySetHelper
,
57 public ::comphelper::OPropertyArrayUsageHelper
<java_sql_Statement_Base
>
61 sal_Int32
getQueryTimeOut() throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
62 sal_Int32
getMaxFieldSize() throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
63 sal_Int32
getMaxRows() throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
64 sal_Int32
getResultSetConcurrency() throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
65 sal_Int32
getResultSetType() throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
66 sal_Int32
getFetchDirection() throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
67 sal_Int32
getFetchSize() throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
68 OUString
getCursorName() throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
70 void setQueryTimeOut(sal_Int32 _par0
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
71 void setMaxFieldSize(sal_Int32 _par0
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
72 void setMaxRows(sal_Int32 _par0
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
73 void setResultSetConcurrency(sal_Int32 _par0
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
74 void setResultSetType(sal_Int32 _par0
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
75 void setFetchDirection(sal_Int32 _par0
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
76 void setFetchSize(sal_Int32 _par0
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
77 void setCursorName(const OUString
&_par0
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
78 void setEscapeProcessing(bool _par0
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
);
81 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XStatement
> m_xGeneratedStatement
;
82 java_sql_Connection
* m_pConnection
;
83 java::sql::ConnectionLog m_aLogger
;
84 OUString m_sSqlStatement
;
86 sal_Int32 m_nResultSetConcurrency
;
87 sal_Int32 m_nResultSetType
;
88 bool m_bEscapeProcessing
;
89 ::cppu::OBroadcastHelper
& rBHelper
;
92 // Static data for the class
93 static jclass theClass
;
95 // OPropertyArrayUsageHelper
96 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const SAL_OVERRIDE
;
98 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() SAL_OVERRIDE
;
100 virtual sal_Bool SAL_CALL
convertFastPropertyValue(
101 ::com::sun::star::uno::Any
& rConvertedValue
,
102 ::com::sun::star::uno::Any
& rOldValue
,
104 const ::com::sun::star::uno::Any
& rValue
105 ) throw (::com::sun::star::lang::IllegalArgumentException
) SAL_OVERRIDE
;
107 virtual void SAL_CALL
setFastPropertyValue_NoBroadcast(
109 const ::com::sun::star::uno::Any
& rValue
110 ) throw (::com::sun::star::uno::Exception
, std::exception
) SAL_OVERRIDE
;
112 virtual void SAL_CALL
getFastPropertyValue(
113 ::com::sun::star::uno::Any
& rValue
,
115 ) const SAL_OVERRIDE
;
117 virtual void createStatement(JNIEnv
* _pEnv
) = 0;
119 virtual ~java_sql_Statement_Base();
121 sal_Int32
impl_getProperty(const char* _pMethodName
, jmethodID
& _inout_MethodID
);
122 sal_Int32
impl_getProperty(const char* _pMethodName
, jmethodID
& _inout_MethodID
,sal_Int32 _nDefault
);
125 virtual jclass
getMyClass() const SAL_OVERRIDE
;
127 // A ctor that is needed for returning the object
128 java_sql_Statement_Base( JNIEnv
* pEnv
, java_sql_Connection
& _rCon
);
130 sal_Int32
getStatementObjectID() const { return m_aLogger
.getObjectID(); }
133 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
135 virtual void SAL_CALL
acquire() throw() SAL_OVERRIDE
;
136 virtual void SAL_CALL
release() throw() SAL_OVERRIDE
;
137 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
142 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
144 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> SAL_CALL
executeQuery( const OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
145 virtual sal_Int32 SAL_CALL
executeUpdate( const OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
146 virtual sal_Bool SAL_CALL
execute( const OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
147 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
, std::exception
) SAL_OVERRIDE
;
149 virtual ::com::sun::star::uno::Any SAL_CALL
getWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
150 virtual void SAL_CALL
clearWarnings( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
152 virtual void SAL_CALL
cancel( ) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
154 virtual void SAL_CALL
close( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
156 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
, std::exception
) SAL_OVERRIDE
;
157 virtual sal_Int32 SAL_CALL
getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
158 virtual sal_Bool SAL_CALL
getMoreResults( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
159 //XGeneratedResultSet
160 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> SAL_CALL
getGeneratedValues( ) throw (::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
163 using ::cppu::OPropertySetHelper::getFastPropertyValue
;
166 class OStatement_BASE2
:public java_sql_Statement_Base
167 ,public OSubComponent
<OStatement_BASE2
, java_sql_Statement_BASE
>
170 friend class OSubComponent
<OStatement_BASE2
, java_sql_Statement_BASE
>;
172 OStatement_BASE2(JNIEnv
* pEnv
, java_sql_Connection
& _rCon
) : java_sql_Statement_Base( pEnv
, _rCon
),
173 OSubComponent
<OStatement_BASE2
, java_sql_Statement_BASE
>(static_cast<cppu::OWeakObject
*>(&_rCon
), this){}
176 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
178 virtual void SAL_CALL
release() throw() SAL_OVERRIDE
;
181 class java_sql_Statement
: public OStatement_BASE2
,
182 public ::com::sun::star::sdbc::XBatchExecution
,
183 public ::com::sun::star::lang::XServiceInfo
186 // Static data for the class
187 static jclass theClass
;
189 virtual void createStatement(JNIEnv
* _pEnv
) SAL_OVERRIDE
;
191 virtual ~java_sql_Statement();
193 DECLARE_SERVICE_INFO();
194 virtual jclass
getMyClass() const SAL_OVERRIDE
;
196 // A ctor that is needed for returning the object
197 java_sql_Statement( JNIEnv
* pEnv
, java_sql_Connection
& _rCon
) : OStatement_BASE2( pEnv
, _rCon
){};
199 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
200 virtual void SAL_CALL
acquire() throw() SAL_OVERRIDE
;
201 virtual void SAL_CALL
release() throw() SAL_OVERRIDE
;
203 virtual void SAL_CALL
addBatch( const OUString
& sql
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
204 virtual void SAL_CALL
clearBatch( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
205 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
executeBatch( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
208 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_JSTATEMENT_HXX
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */