28#include <com/sun/star/lang/DisposedException.hpp>
35#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
36#include <com/sun/star/sdbc/ResultSetType.hpp>
45using namespace ::
cppu;
57jclass java_sql_Statement_Base::theClass =
nullptr;
64 ,m_pConnection( &_rCon )
65 ,m_aLogger( _rCon.getLogger(), java::
sql::ConnectionLog::STATEMENT )
66 ,m_nResultSetConcurrency(ResultSetConcurrency::READ_ONLY)
67 ,m_nResultSetType(ResultSetType::FORWARD_ONLY)
68 ,m_bEscapeProcessing(true)
84 static jmethodID mID(
nullptr);
105 java_sql_Statement_BASE::disposing();
114 Any aRet( java_sql_Statement_BASE::queryInterface(rType) );
124 Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes();
127 auto [
begin,
end] = asNonConstRange(aOldTypes);
128 auto newEnd = std::remove(
begin,
end,
130 aOldTypes.realloc(std::distance(
begin, newEnd));
133 return ::comphelper::concatSequences(
aTypes.getTypes(),aOldTypes);
139 ::osl::MutexGuard aGuard(
m_aMutex );
142 jobject out(
nullptr);
148 static jmethodID mID(
nullptr);
151 catch(
const SQLException&)
156 Reference< XResultSet > xRes;
159 OSL_ENSURE(
m_pConnection.is() &&
m_pConnection->isAutoRetrievingEnabled(),
"Illegal call here. isAutoRetrievingEnabled is false!");
163 if ( !sStmt.isEmpty() )
182 static jmethodID mID(
nullptr);
190 ::osl::MutexGuard aGuard(
m_aMutex );
191 if (java_sql_Statement_BASE::rBHelper.bDisposed)
192 throw DisposedException();
204 static jmethodID mID(
nullptr);
213 ::osl::MutexGuard aGuard(
m_aMutex );
222 static const char *
const cSignature =
"(Ljava/lang/String;)Z";
223 static const char *
const cMethodName =
"execute";
225 static jmethodID mID(
nullptr);
236 out =
t.pEnv->CallBooleanMethod(
object, mID, str.
get() );
246 ::osl::MutexGuard aGuard(
m_aMutex );
250 jobject out(
nullptr);
257 static const char *
const cSignature =
"(Ljava/lang/String;)Ljava/sql/ResultSet;";
258 static const char *
const cMethodName =
"executeQuery";
260 static jmethodID mID(
nullptr);
271 out =
t.pEnv->CallObjectMethod(
object, mID, str.
get() );
281 ::osl::MutexGuard aGuard(
m_aMutex );
289 Any aRet = ::cppu::queryInterface(rType,
static_cast< XBatchExecution*
> (
this));
296 ::osl::MutexGuard aGuard(
m_aMutex );
301 static jmethodID mID(
nullptr);
309 ::osl::MutexGuard aGuard(
m_aMutex );
311 Sequence< sal_Int32 >
aSeq;
314 static jmethodID mID(
nullptr);
315 jintArray out =
static_cast<jintArray
>(
callObjectMethod(
t.pEnv,
"executeBatch",
"()[I", mID));
319 aSeq.realloc(
t.pEnv->GetArrayLength(out));
320 memcpy(
aSeq.getArray(),
t.pEnv->GetIntArrayElements(out,&
p),
aSeq.getLength());
321 t.pEnv->DeleteLocalRef(out);
329 ::osl::MutexGuard aGuard(
m_aMutex );
336 static jmethodID mID(
nullptr);
345 static jmethodID mID(
nullptr);
357 static jmethodID mID(
nullptr);
366 static jmethodID mID(
nullptr);
375 static jmethodID mID(
nullptr);
376 jobject out =
callObjectMethod(
t.pEnv,
"getWarnings",
"()Ljava/sql/SQLWarning;", mID);
382 static_cast< css::sdbc::SQLException
>(
391 ::osl::MutexGuard aGuard(
m_aMutex );
397 static jmethodID mID(
nullptr);
404 static jmethodID mID(
nullptr);
410 static jmethodID mID(
nullptr);
416 static jmethodID mID(
nullptr);
423 static jmethodID mID(
nullptr);
429 sal_Int32 out = _nDefault;
444 static jmethodID mID(
nullptr);
450 static jmethodID mID(
nullptr);
456 static jmethodID mID(
nullptr);
462 ::osl::MutexGuard aGuard(
m_aMutex );
466 static jmethodID mID(
nullptr);
471 catch(
const SQLException&)
479 ::osl::MutexGuard aGuard(
m_aMutex );
483 static jmethodID mID(
nullptr);
490 ::osl::MutexGuard aGuard(
m_aMutex );
497 static jmethodID mID(
nullptr);
503 ::osl::MutexGuard aGuard(
m_aMutex );
507 static jmethodID mID(
nullptr);
513 ::osl::MutexGuard aGuard(
m_aMutex );
523 ::osl::MutexGuard aGuard(
m_aMutex );
533 ::osl::MutexGuard aGuard(
m_aMutex );
538 static jmethodID mID(
nullptr);
544 ::osl::MutexGuard aGuard(
m_aMutex );
550 static jmethodID mID(
nullptr);
556 ::osl::MutexGuard aGuard(
m_aMutex );
560 static jmethodID mID(
nullptr);
566 ::osl::MutexGuard aGuard(
m_aMutex );
571 static jmethodID mID(
nullptr);
579 return new ::cppu::OPropertyArrayHelper
654 Any & rConvertedValue,
664 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue,
getQueryTimeOut());
666 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue,
getMaxFieldSize());
668 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue,
getMaxRows());
670 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue,
getCursorName());
674 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue,
getResultSetType());
676 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue,
getFetchDirection());
678 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue,
getFetchSize());
680 return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue,
m_bEscapeProcessing );
687 catch(
const css::lang::IllegalArgumentException&)
691 catch(
const css::uno::Exception&)
802 ::osl::MutexGuard aGuard(
m_aMutex );
805 if( !_pEnv ||
object )
809 static const char *
const cMethodName =
"createStatement";
811 jobject out =
nullptr;
812 static jmethodID mID(
nullptr);
815 static const char *
const cSignature =
"(II)Ljava/sql/Statement;";
816 mID = _pEnv->GetMethodID(
m_pConnection->getMyClass(), cMethodName, cSignature );
823 static const char *
const cSignature2 =
"()Ljava/sql/Statement;";
824 static jmethodID mID2 = _pEnv->GetMethodID(
m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,
"Unknown method id!");
826 out = _pEnv->CallObjectMethod(
m_pConnection->getJavaObject(), mID2);
832 object = _pEnv->NewGlobalRef( out );
840 java_sql_Statement_BASE::acquire();
845 java_sql_Statement_BASE::release();
860 return ::cppu::OPropertySetHelper::createPropertySetInfo(
getInfoHelper());
IMPLEMENT_SERVICE_INFO(java_sql_Statement,"com.sun.star.sdbcx.JStatement","com.sun.star.sdbc.Statement")
::cppu::IPropertyArrayHelper * getArrayHelper()
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL disposing() override
void log(const sal_Int32 _nLogLevel, const OUString &rMessage)
logs a given message, without any arguments, or source class/method names
jobject callObjectMethod(JNIEnv *pEnv, const char *_pMethodName, const char *_pSignature, jmethodID &_inout_MethodID) const
jobject callResultSetMethod(JNIEnv &_rEnv, const char *_pMethodName, jmethodID &_inout_MethodID) const
sal_Int32 callIntMethod_ThrowSQL(const char *_pMethodName, jmethodID &_inout_MethodID) const
bool callBooleanMethod(const char *_pMethodName, jmethodID &_inout_MethodID) const
sal_Int32 callIntMethodWithStringArg(const char *_pMethodName, jmethodID &_inout_MethodID, const OUString &_nArgument) const
void callVoidMethodWithStringArg(const char *_pMethodName, jmethodID &_inout_MethodID, const OUString &_nArgument) const
void callVoidMethod_ThrowSQL(const char *_pMethodName, jmethodID &_inout_MethodID) const
void callVoidMethodWithBoolArg_ThrowRuntime(const char *_pMethodName, jmethodID &_inout_MethodID, bool _nArgument) const
void callVoidMethodWithIntArg_ThrowRuntime(const char *_pMethodName, jmethodID &_inout_MethodID, sal_Int32 _nArgument) const
OUString callStringMethod(const char *_pMethodName, jmethodID &_inout_MethodID) const
sal_Int32 callIntMethod_ThrowRuntime(const char *_pMethodName, jmethodID &_inout_MethodID) const
static void ThrowLoggedSQLException(const ::comphelper::EventLogger &_rLogger, JNIEnv *pEnvironment, const css::uno::Reference< css::uno::XInterface > &_rxContext)
static jclass findMyClass(const char *_pClassName)
void callVoidMethod_ThrowRuntime(const char *_pMethodName, jmethodID &_inout_MethodID) const
void obtainMethodId_throwSQL(JNIEnv *_pEnv, const char *_pMethodName, const char *_pSignature, jmethodID &_inout_MethodID) const
void setEscapeProcessing(bool _par0)
java::sql::ConnectionLog m_aLogger
virtual void SAL_CALL close() override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getGeneratedValues() override
sal_Int32 impl_getProperty(const char *_pMethodName, jmethodID &_inout_MethodID)
virtual css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
sal_Int32 getResultSetType()
virtual jclass getMyClass() const override
virtual css::uno::Any SAL_CALL getWarnings() override
void setMaxRows(sal_Int32 _par0)
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
virtual void SAL_CALL clearWarnings() override
css::uno::Reference< css::sdbc::XStatement > m_xGeneratedStatement
virtual sal_Bool SAL_CALL execute(const OUString &sql) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
void setQueryTimeOut(sal_Int32 _par0)
void setFetchDirection(sal_Int32 _par0)
sal_Int32 m_nResultSetConcurrency
virtual sal_Bool SAL_CALL getMoreResults() override
virtual sal_Int32 SAL_CALL executeUpdate(const OUString &sql) override
sal_Int32 getResultSetConcurrency()
void setFetchSize(sal_Int32 _par0)
void setResultSetType(sal_Int32 _par0)
sal_Int32 m_nResultSetType
virtual ~java_sql_Statement_Base() override
virtual void SAL_CALL release() noexcept override
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(const OUString &sql) override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
virtual sal_Int32 SAL_CALL getUpdateCount() override
rtl::Reference< java_sql_Connection > m_pConnection
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL cancel() override
void setCursorName(const OUString &_par0)
sal_Int32 getFetchDirection()
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet() override
void setResultSetConcurrency(sal_Int32 _par0)
sal_Int32 getQueryTimeOut()
virtual void createStatement(JNIEnv *_pEnv)=0
sal_Int32 getMaxFieldSize()
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
void setMaxFieldSize(sal_Int32 _par0)
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual void SAL_CALL clearBatch() override
virtual void createStatement(JNIEnv *_pEnv) override
virtual css::uno::Sequence< sal_Int32 > SAL_CALL executeBatch() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual ~java_sql_Statement() override
virtual void SAL_CALL addBatch(const OUString &sql) override
virtual void SAL_CALL acquire() noexcept override
virtual jclass getMyClass() const override
virtual void SAL_CALL release() noexcept override
helper class to hold a local ref to a JNI object
mutable::osl::Mutex m_aMutex
css::uno::Type const & get()
#define DBG_UNHANDLED_EXCEPTION(...)
Sequence< sal_Int8 > aSeq
sal_Int32 getINT32(const Any &_rAny)
OUString getString(const Any &_rAny)
::cppu::WeakComponentImplHelper< css::sdbc::XStatement, css::sdbc::XWarningsSupplier, css::util::XCancellable, css::sdbc::XCloseable, css::sdbc::XGeneratedResultSet, css::sdbc::XMultipleResults > java_sql_Statement_BASE
jstring convertwchar_tToJavaString(JNIEnv *pEnv, const OUString &Temp)
void checkDisposed(bool _bThrow)
enumrange< T >::Iterator begin(enumrange< T >)
#define PROPERTY_ID_RESULTSETTYPE
#define PROPERTY_ID_QUERYTIMEOUT
#define PROPERTY_ID_USEBOOKMARKS
#define PROPERTY_ID_CURSORNAME
#define PROPERTY_ID_RESULTSETCONCURRENCY
#define PROPERTY_ID_MAXFIELDSIZE
#define PROPERTY_ID_FETCHSIZE
#define PROPERTY_ID_MAXROWS
#define PROPERTY_ID_ESCAPEPROCESSING
#define PROPERTY_ID_FETCHDIRECTION
constexpr OUStringLiteral STR_LOG_FETCH_DIRECTION
constexpr OUStringLiteral STR_LOG_RESULT_SET_TYPE
constexpr OUStringLiteral STR_LOG_EXECUTE_UPDATE
constexpr OUStringLiteral STR_LOG_CLOSING_STATEMENT
constexpr OUStringLiteral STR_LOG_EXECUTE_QUERY
constexpr OUStringLiteral STR_LOG_SET_ESCAPE_PROCESSING
constexpr OUStringLiteral STR_LOG_GENERATED_VALUES
constexpr OUStringLiteral STR_LOG_EXECUTE_STATEMENT
constexpr OUStringLiteral STR_LOG_UPDATE_COUNT
constexpr OUStringLiteral STR_LOG_FETCH_SIZE
constexpr OUStringLiteral STR_LOG_RESULT_SET_CONCURRENCY
constexpr OUStringLiteral STR_LOG_GENERATED_VALUES_FALLBACK